MySQL installation tutorial
Mysql installation tutorial
Prepare the mysql installation package in advance (download address: http://mirrors.sohu.com/mysql/MySQL-5.6/)
The editor here uses: mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
If necessary, contact the editor to pass the package to you.
Step 1: create a directory
Mkdir-p / home/lsy/tools
Step 2: transfer the downloaded installation package to the / home/lsy/tools directory.
Cd / home/lsy/tools
Rz mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
Step 3: extract the mysql binary package
Tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
Step 4: add administrative users when the mysql program is running
Useradd-s / sbin/nologin-M mysql
Step 5: move the extracted mysql package to the program directory and rename it
Mkdir-p / application/
Mv / home/lsy/tools/mysql-5.6.34-*-x86_64 / application/mysql-5.6.34
Step 6: create a soft link for the mysql service
Ln-s / application/mysql-5.6.34/ / application/mysql
Step 7: let mysql users manage / application/mysql/
Chown-R mysql.mysql / application/mysql/
Step 8: initialize the database
# 1. Confirm where the software is installed
# 2. Confirm where the data is stored
# 3. Who is the user who confirms the use of MySQL?
/ application/mysql/scripts/mysql_install_db-basedir=/application/mysql-datadir=/application/mysql/data-user=mysql
(the mysql startup script is placed on support-files/mysql.server by default)
Step 9: copy startup script authorization
Cp / application/mysql/support-files/mysql.server / etc/init.d/mysqld
Chmod + x / etc/init.d/mysqld
Step 10: modify the path in the startup script and mysql command
Sed-I's accountUniverse usr _ application/mysql/bin/mysqld_safe _ etc/init.d/mysqld _ MySQL
Step 11: copy the default profile
\ cp / application/mysql/support-files/my-default.cnf / etc/my.cnf
Step 12: start mysql
/ etc/init.d/mysqld start
Step 13: set the mysql password
/ application/mysql/bin/mysqladmin-u root password '123456'
Step 14: simplify the login database command
Echo 'export PATH=/application/mysql/bin:$PATH' > > / etc/profile
Write variables and restart
Source / etc/profile
Check to see if you have changed
[root@mysql] # which mysql
/ application/mysql/bin/mysql
Step 15: set the mysql service to boot automatically
Join the boot self-boot
Chkconfig-add mysqld
Chkconfig mysqld on
Step 16: two ways to enter mysql
[root@mysql] # mysql-u root-p123456
[root@mysql] # mysql-uroot-p
Enter password:123456
Step 17: the way to exit mysql
Enter quit directly on the command line
Or using CTRL + D on the command line is not recommended for CTRL + C