Preface
MySQL is a powerful relational database system that is widely used. When using MySQL, you need to download the installation package first, and then install and configure it before you can start using it. This process is relatively cumbersome. This article will introduce a way to avoid installing MySQL.
This article will introduce how to configure the installation-free version of MySQL, and demonstrate through examples how to use the installation-free MySQL to create databases, tables, and add, delete, modify, and query operations. If you are interested in database operations or need to learn the use of MySQL, then this article will be a good choice.
1. Download the installation-free MySQL
We can download the installation-free version of MySQL from the official website http://dev.mysql.com/downloads/mysql/.
When downloading, you need to select the version corresponding to the operating system. For example: Windows 64-bit version needs to download the "Windows (x86, 64-bit), ZIP Archive" file. After the download is complete, unzip the compressed package to a path of your choice.
2. Configure MySQL without installation
Create a data
folder to store MySQL data files, as shown below:
mkdir data
Create in the MySQL root directorymy.ini
Configuration file, the file content is as follows:
[mysqld] basedir=./ datadir=./data port=3306 character_set_server=utf8mb4 collation-server=utf8mb4_general_ci skip-grant-tables
basedir
: MySQL installation path datadir
: Path to store data files port
: The port of the MySQL service, the default is 3306character_set_server
and collation-server
:Set the default character set and collation of the MySQL databaseEnter the following command in the CMD command line to start the MySQL service:
binmysqld --console
After executing the above command, if you see output similar to the picture below, it means that the MySQL service is started successfully:
After the MySQL service is started , use the following command to log in to the MySQL command prompt:
binmysql -uroot -p
After entering the password, you can enter the MySQL command line.
Use the following command in MySQL to change the password:
use mysql; update user set authentication_string=password('你的密码') where user='root'; flush privileges;
Note: If you encounter "Access denied for user 'root' @'localhost' (using password: NO)" error, you can add the password in the connection command, for example:
binmysql -uroot -p你的密码
and then execute the above command to change the password.
At this point, the installation-free version of MySQL has been configured.
3. Use of MySQL without installation
After the MySQL configuration is completed, we can learn how to use MySQL without installation to create databases and tables through the following examples. Operations such as creation, addition, deletion, modification, and query.
Create database
First, we need to create a database named test
, which can be done using the following command:
create database test;
After executing the above command, a database named test
can be created in MySQL.
Create table
After creating the database, we need to create the data table. Take creating a table named students
as an example. The table contains two fields: name and age.
use test; create table students( id int(11) primary key auto_increment, name varchar(20), age int(3) )engine=innodb default character set utf8mb4 collate=utf8mb4_general_ci;
After executing the above command, you can create a file named test
in MySQL, including id
, name
, age
Three-column data tablestudents
. It should be noted that the innodb
engine is used in the table created in this article, and the default character set and collation of the database are utf8mb4
and utf8mb4_general_ci
.
Insert data
After creating the data table, we can insert data into the data table. Take inserting a piece of data into the students
table as an example:
insert into students(name, age) values('张三', 20);
Query data
After inserting data, we need to query the data. Take querying all the data in the students
table as an example:
select * from students;
After executing the above command, all the data in the students
table will be listed in MySQL.
Update data
If we need to update the data, we can use the following command to add all the records named "Zhang San" in the students
table Change the age to 22:
update students set age=22 where name='张三';
Delete data
Finally, if we need to delete data, we can use the following command to delete all data in the students
table Deletion of records named "Zhang San":
delete from students where name='张三';
Conclusion
Through the introduction in this article, I believe readers have understood how to configure and use the MySQL installation-free version. And how to use MySQL for basic database operations. MySQL is a powerful relational database system that is widely used. If you need to learn database knowledge or perform database operations, MySQL will be a good choice.
The above is the detailed content of No need to install mysql configuration. For more information, please follow other related articles on the PHP Chinese website!