Linux under Install configuration MySQL server

Source: Internet
Author: User

Linux under Install configuration MySQL server

First, installation Environment ============

os:centos6.8

Mysql:mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

installation directory:/usr/local/mysql57installed with the root user.

Second, installation steps ============1, unzip the installation package [root] #cd/usr/local[root] #mv/path/to/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz .[Root] #tar-xzf Mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz[root] #mkdir Mysql57[root] #mv Mysql-5.7.16-linux-glibc2.5-x86_64 Mysql57/mysql The above steps, MySQL is installed in the/usr/local/mysql directory. 2. Create MySQL user and MySQL user group [root] #groupadd MySQL [root] #useradd-r-s/bin/false-g MySQL MySQL 3, create and initialize data directory [root] #cd/usr/l Ocal/mysql57[root] #mkdir data #创建数据目录 [root] #chown-R mysql:mysql  .[Root] #bin/mysqld--user=mysql--basedir=/usr/local/mysql57/mysql--datadir=/usr/local/mysql57/data-- Initialize-insecure #初始化数据目录 [Root] #chown-R root:root .[Root] #chown-R mysql:mysql Data

4. Modify the MySQL configuration file [root] #cp/usr/local/mysql57/mysql/support-files/my-default.cnf/etc/my.cnf[root] #vi/etc/ MY.CNF in which to set: [Mysqld]basedir =/usr/local/mysql57/mysqldatadir =/usr/local/mysql57/dataport = 3306 Save exit.

5. Start the MySQL database server [root] #cd/usr/local/mysql57/mysql[root] #bin/mysql_safe--user=mysql & 6, log in to the MySQL server and modify the root user password [   Root] #cd/usr/local/mysql57/mysql[root] #mysql-uroot-pmysql>set password=password (' 123456 '); #设置root密码为123456mysql >quit; 7. Add remote access permission [root] #mysql-uroot-pmysql>grant all privileges on * * to [email protected] '% ' identified by ' 123456 '; mysql& Gt;flush privileges;mysql>quit;

8. Add bin to PATH environment variable add the following in/etc/profile: Export path=/usr/local/mysql57/mysql/bin: $PATH save exit, then Source/etc/profile 9, Set up MySQL server boot from [root] #cp/usr/local/mysql57/mysql/support-files/mysql.server/etc/init.d/mysqld[root] #vi/etc/ Init.d/mysqld Open the Mysqld file and enter the correct path in Basedir and DataDir. Basedir=/usr/local/mysql57/mysqldatadir=/usr/local/mysql57/data Save exit. #设置开机自启动 [Root] #chkconfig--add Mysqld[root] #chkconfig--level 345 mysqld on this configures the MySQL server.

Third, connect MySQL server ========================

There are two ways to connect to a MySQL server: Local connection and remote connection.

1. Local connectionA local connection, also known as a socket connection, refers to a connection created through a socket file on the same machine as the MySQL server. Usually to check the status of MySQL server, you can log on to the MySQL server on the machine, connect to the MySQL server by local connection, to check the status of the MySQL server. Or in the application development process, the application and MySQL deployed on the same machine, the connection to the MySQL server can be done by local connection. Create a Mysql.sock socket file $mysql-s/tmp/mysql.sock-uroot-p #mysql服务器启动后一般在/tmp directory

2. Remote ConnectionA remote connection, also known as a TCP/IP connection, refers to the way a MySQL server is connected from a server or client other than a MySQL server. The only difference between a remote connection and a local connection is that the remote connection needs to specify the IP address of the MySQL server and the port number it listens on. By, when the MySQL server and application server are deployed on different servers, it is necessary to remotely connect to the MySQL server from the application server to operate the MySQL server. $mysql-h127.0.0.1-p3306-uroot-p

Linux under Install configuration MySQL server

Related Article

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.