Linux installation MySQL database for test environment
1. First determine the version of your system and choose the appropriate mysql version
Cat / proc/version
2. Mysql download link address
Https://dev.mysql.com/downloads/mysql/
3. Upload, file rz
4. Extract the file
Tar-zxvf mysql-5.6.36-linux-glibc2.5-i686.tar.gz
5. Copy the decompressed file
Cp mysql-5.6.36-linux-glibc2.5-i686 / usr/local/mysql-r
Details: when you didn't install mysql before, now cp is equivalent to moving the directory mysql-5.6.36-linux-glibc2.5-i686.
And rename it to: mysql. You don't need to create a mysql directory first.
If you create mysql first, it will appear: / usr/local/mysql/mysql-5.6.36-linux-glibc2.5-i686, and then there will be problems with the installation.
6. Create user groups, create users, modify newly created passwords
Groupadd mysql
Useradd-r-g mysql mysql
Passwd mysql-then enter the password twice
7. Change to the directory mysql for file authorization and database installation
Cd / usr/local/mysql/
Chown-R-v mysql:mysql. /-- modify the owner of all files in the current directory to: mysql
. / scripts/mysql_install_db-- user=mysql
Chown-R root:root. / modify the owner of all files in the current directory as: mysql
Chown-R mysql:mysql data modifies the owner of all files under the current directory data to: mysql
8. Add boot up and put the startup script in the boot initialization directory
Welcome to join the test communication group (1017539290). You can discuss the topics you are interested in online with Daniel at any time, so that you can learn the most in the least time.
Cp support-files/mysql.server / etc/init.d/mysql
9. Start the mysql service
Service mysql start
Several commands about the mysql service
Service mysql start: Starting MYSQL. [OK]
Service mysql status: MySQL running (4095) [OK]
Service mysql stop: Shutting down MySQL.. [OK]
Service mysql restart: Shutting down MySQL.. [confirm] Starting MySQL. [OK]
10. Change to the mysql directory to change the password of root
Cd / usr/local/mysql
. / bin/mysqladmin-u root password 'root'
11. Put the mysql client in the default path
Ln-s / usr/local/mysql/bin/mysql / usr/local/bin/mysql
twelve。 Log into the database
Mysql-u root-p-enter the root password to log in
Show databases
Use mysql
Select host,user from user where user='root'