Linux installation mysql-5.7.17

Source: Internet
Author: User

I. Check if the system has its own installation MySQL1. Check
[Email protected] ~]# Rpm-qa | Grep-i mysqlmysql-libs-5.1.71-1.el6.x86_64
2. Uninstall
[[email protected] ~]# rpm-e--nodeps mysql-libs-5.1.71-1.el6.x86_64[[email protected] ~]# Rpm-qa | Grep-i mysqlrpm-e--noscripts mysql-client-5.5.25a-1.rhel5rm-fr deleting files
Second, decompression and renaming
[Email protected] ~]# TAR-ZXVF mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz-c/data/[[email protected] ~]# mv mysql-5.7.1 7-linux-glibc2.5-x86_64/mysql-5.7.17
Third, set up users and user groups to assign permissions to MySQL 1. Build user MySQL, group MySQL. MySQL uses this user to run later (note that this is also the default user in the MySQL startup script, so it is best not to rename).
[[email protected] mysql-5.7.17]# groupadd mysql[[email protected] mysql-5.7.17]# useradd-r-g MySQL MySQL
(using the-R parameter indicates that the MySQL user is a system user and cannot log on) 2. Manually create MySQL Data directory
[Email protected] data]# Mkdir/data/mysql-5.7/data
3. Directory Permissions settings

Set MySQL and all of its directory owners and groups to MySQL:

[Email protected] mysql-5.7]# chown-r mysql:mysql/data/mysql-5.7/[[email protected] mysql-5.7]# chmod 755/data/mysql- 5.7./
Iv. Database Initialization
[Email protected] bin]#/mysqld--initialize--user=mysql--datadir=/data/mysql-5.7/data--basedir=/data/mysql-5.7

Initialize the initial password to complete the record, log in to the database to use

[Email protected]: TSYB; K9rwrk6
Five, configuration

Rename the Mysql/support-files under the my-default.cnf to MY.CNF, copy to/etc (or test to {mysql}, and then make a soft link to/etc):

[Email protected] support-files]# CP/DATA/MYSQL-5.7.17/SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF

To modify the key configuration in/ETC/MY.CNF:

[[email protected] support-files]# Vim/etc/my.cnf[mysqld] Basedir =/data/mysql-5.7.17 DataDir =/data/mysql-5.7.17/ Data Port = 3306 Socket =/data/mysql-5.7.17/tmp/mysql.sock

Note that the TMP directory does not exist, please create it.

[Email protected] data]# mkdir/data/mysql-5.7.17/tmp
Vi. running 1. Re-assigning permissions to the MySQL directory before running
[Email protected] mysql-5.7.17]# chown mysql:mysql/data/mysql-5.7/[[email protected] data]# chmod 755/data/ mysql-5.7.17/
2. Running the server program
[Email protected] bin]#./mysqld_safe &

  

Note: The default setting in this startup script is--user=mysql; add & at the end of the script to set this process as a background process, the difference is that in the console input BG, the current process can be transferred to the background, the current shell can do other operations.

May have an error:

2017-10-11t13:04:21.482778z mysqld_safe Logging to '/data/mysql-5.7/data/centos.xd.err '. 2017-10-11t13:0 4:21.485731z Mysqld_safe The File/usr/local/mysql/bin/mysqlddoes not exist or is not executable. Please CD to the MySQL installationdirectory and restart this script from there as Follows:./bin/mysqld_safe&see http: Dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

Description: The Mysqld_safe startup script reads the other startup script from the/usr/local/mysql directory by default mysqld, because my installation directory is/data/mysql-5.17/bin/mysqld, so the related files cannot be found.
Workaround:

[Email protected] mysql-5.7]# mkdir-p/usr/local/mysql/bin/[[email protected] MySQL-5.7]# ln-s/data/mysql-5 .7/bin/mysqld/usr/local/mysql/bin/
3. Set up MySQL to run as a service

Copy {mysql}/support-files/mysql.server to/etc/init.d/mysql and set run permissions

[Email protected] data]# Cp/data/mysql-5.7/support-files/mysql.server/etc/init.d/mysql[[email protected] data]# chmod +x/etc/init.d/mysql
4. Start MySQL
[[email protected] data]#/etc/init.d/mysql start

  

Errors may occur:
1:starting mysql.logging to '/data/mysqldata/localhost.localdomain.err '.
error! The server quit without updating PID file (/data/mysqldata/localhost.localdomain.pid).
Bin/mysqld–initialize–user=mysql is the key, and then reinstall the

2:mysql [ERROR] Table ' mysql.user ' doesn ' t exist
Check that the/ETC/MY.CNF configuration is correct DataDir
Reboot after check

[[email protected] mysql-5.7]#/etc/init.d/mysql startstarting MySQL. success!
5. Connect to the database
[Email protected] ~]# mysql-uroot-p

  

Errors may occur:
1:-bash:mysql:command not found
Linking the Mysql/bin/mysql command to Usr/bin/mysql X

[Email protected] ~]# ln-s/usr/local/mysql/bin/mysql/usr/bin/mysql

2:error 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)
You need to fill in the MY.CNF:
[Client]
Socket =/data/mysql-5.7/tmp/mysql.sock

If not, use the soft link:

[Email protected] tmp]# ln-s/data/mysql-5.7/tmp/mysql.sock/tmp/mysql.sock

Startup success

[[email protected] mysql-5.7]# mysql-uroot-penter Password: Enter the password recorded when initializing the database Welcome to the MySQL Monitor.  Commands End With; or \g.your MySQL connection ID is 3Server version:5.7.17 mysql Community Server (GPL)

Set the root user password

Mysql> set Password=password (' 123456 '); Query OK, 0 rows affected, 1 warning (0.03 sec)

Give all permissions to the root account

Mysql> Grant all privileges on * * to [e-mail protected] ' localhost ' identified by' 123456 ' 0 rows affected, 1 WA Rning (0.00 sec)

Refresh

mysql> flush Privileges; Query OK, 0 rows Affected (0.00 sec)

Quit MySQL

Mysql> exit; Bye
Registering MySQL as a boot-start service
#chkconfig--add MySQL Usage example: chkconfig--list        #列出所有的系统服务chkconfig--add httpd        #增加httpd服务chkconfig--del httpd        #删除httpd服务chkconfig--level httpd 2345        on #设置httpd在运行级别为2, 3, 4, 5 in the case of On (open) status Chkconfig--list        # List all service boot conditions for the system chkconfig--list mysqld        #列出mysqld服务设置情况chkconfig--level mysqld on        #设定mysqld在等级3和5为开机运行服务,-- Level 35 indicates that the operation is performed only at levels 3 and 5, on indicates start, off Chkconfig mysqld on        #设定mysqld在各等级为on, and "levels" include 2, 3, 4, 5 levels How to add a service: 1. Service scripts must be stored in /etc/ini.d/directory; 2.chkconfig--add ServiceName    Add this service to the Chkconfig tool Service list, where the service is given/ETC/RC.D/RCN.D entry in k/s ; 3.chkconfig--level mysqld    on Modify the default boot level for the service.
The MySQL service is turned on and off:
View MySQL's installation directory
[Email protected] mysql-5.7]# Whereis mysqlmysql:/usr/bin/mysql/usr/lib64/mysql/usr/local/mysql/usr/share/mysql
View the running directory for MySQL
[email protected] mysql-5.7]# which mysql/usr/bin/mysql

  

Linux installation mysql-5.7.17

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.