Home >Database >Mysql Tutorial >How to configure mysql after downloading it
In order to configure the downloaded MySQL, you need to complete the following steps: download MySQL and install it; initialize MySQL; modify the configuration file (change the root password, set connection parameters); create the mysqld service; start MySQL; connect through the MySQL shell Go to MySQL; create database and user.
MySQL configuration guide after downloading
1. Download MySQL
Visit the MySQL official website https://www.mysql.com/downloads/ to download the MySQL version suitable for your operating system.
2. Install MySQL
Follow the instructions in the installation wizard to install. Make sure to select the "Custom" installation option so you can choose the installation path and configuration options.
3. Initialize MySQL
After the installation is complete, open a command prompt or terminal window and run the following command:
<code>mysql_install_db --user=mysql --basedir=/path/to/mysql --datadir=/path/to/data</code>
4 . Configure MySQL
Open the MySQL configuration filemy.cnf
(usually located at /etc/mysql/my.cnf
or /usr/local/mysql/etc/my.cnf
), make the following modifications as needed:
[mysql]
section and add password=new_password
. bind-address
, port
, and max_connections
to suit your specific need. On a Linux system, run the following command to create the mysqld service:
<code>sudo systemctl enable mysqld</code>
On Windows systems, run the following command to create the mysqld service:
<code>net start mysql</code>
5. Start MySQL
Use the following command to start MySQL:
<code>sudo systemctl start mysqld</code>
6. Connect to MySQL
Use the following command to connect to MySQL through the MySQL shell:
<code>mysql -u root -p</code>
Enter the root password you set in step 4.
7. Create a database and user
Create a database and user:
<code>CREATE DATABASE database_name; CREATE USER 'username' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON database_name.* TO 'username';</code>
Now, you have successfully configured MySQL.
The above is the detailed content of How to configure mysql after downloading it. For more information, please follow other related articles on the PHP Chinese website!