Steps and screenshots for installing MySql in Linux, and installing mysql in linux
Refer to the following link for more technical tips: Alibaba Cloud blog
The following is a record in my work. We will introduce the installation process and screenshot of installing MySql using officially compiled binary files in linux. This installation method is fast and the installation steps are simple!
If you want to install MySql quickly, follow these steps :)!
1. Download the binary installation package for mysql linux:
Address: http://dev.mysql.com/downloads/mysql/
Here I rename the installation package to: tingyun-mysql-5.6.22.tar.gz
Note: You can choose not to rename the file as needed.
2. Unzip the installation package:
Decompress the installation package at the desired location: run the following command:
cd /opt tar –xPf tingyun-mysql-5.6.22.tar.gz
Screenshots are as follows:
3. Create the mysql installation directory and modify the directory permissions:
Run the following command:
Create a mysql Directory: mkdir mysql
Open the mysql Directory: cd mysql
Create data directory: mkdir data
Note: Because the mysql service process mysqld will access the data directory during running, you need to create the data directory.
Run the following command in the mysql directory to set the directory owner to a mysql user:
chown mysql:mysql /opt/mysql –R
Screenshots are as follows:
5. Install mysql
Run the installation command mysql_install_db In the mysql directory:
./scripts/mysql_install_db --user=mysql –datadir=/opt/mysql/data
Screenshots are as follows:
6. Start mysql
Go to the init. d directory and run the following command:
cd /etc/init.d/mysqld restart
If you do not want to restart the instance, you can manually start the instance and run the following command:
service mysqld start
You can also directly execute the following command in the mysql directory:
/etc/init.d/mysqld restart
Screenshots are as follows:
7. Create a soft link for mysql
Run the following command:
ln –s /opt/mysql/bin/mysql /user/bin
Screenshots are as follows:
8. Modify mysql Configuration
Run the following command to edit the file:
vim .bash_profile
Description: configure the directory for using./mysql (for example, using./mysql in the bin directory)
(1) write at the bottom of the bash_profile File
Export PATH = $ PATH:/usr/local/mysql/bin (your installation bin directory)
Run the wq command to save and exit.
(2) execute the source command to make the system configuration take effect:
source /.bash_profile
Screenshots are as follows:
9. Security Configuration Wizard
After installing Mysql, You need to configure the security of mysql according to the Security Configuration:
Run the following command to configure the security of the mysql root User:
mysql_secure_installation
Select "Y" for the new password, and enter the new password twice (the second is used as the confirmation password ).
Delete anonymous users and select "Y"
Screenshots are as follows:
You can also set a password for the root user as follows:
Run the following command:
mysql –uroot –pnbs2o13
Screenshots are as follows:
View the content in the mysql installation directory
Screenshots are as follows:
10. Test mysql after installation:
(1) Check whether mysql has been started:
You can use either of the following three commands:
netstat -tl | grep mysqlps -aux | grep mysqldnetstat -lntup|grep 3306
The mysql-related process is printed on the screen and the following similar content is displayed:
tcp 0 0 *:mysql *:* LISTEN
Mysql has been started successfully!
(2) to use mysql, run the following command to access mysql:
mysql -u root -p
(3) view the version:
select version();
So far, mysql has been installed and tested successfully, so you can use it with confidence :)
Link: http://blog.tingyun.com/web/article/detail/1255