Use text instructions for installing MySQL5.6.24 in Linux, and install mysql5.6 in linux

Source: Internet
Author: User

Use text instructions for installing MySQL5.6.24 in Linux, and install mysql5.6 in linux

Notes for installing MySQL in Linux

1. Before installing the MySQL database server, make sure that your linux system can be connected to the network. Next we will install mysql through the source code and log in to your Linux system through putty, make sure that the gcc c ++ compiling environment has been installed in the system, because mysql has been compiled using cmake since mysql 5.5. If none of the three environments are installed, run the following command to install yum-y install make gcc-c ++ cmake bison-devel ncurses-devel.

2. Check whether mysql database components have been installed in the system. Run the command "rpm-qa | grep mysql" to find them. If yes, run the following command to force uninstall: rpm-e -- nodeps package name

If you use the default installation option when installing the Linux system, skip this step;

3, then we download the mysql source code installation package, use the following command to download wget http://xiazai.jb51.net/201701/yuanma/mysql5.6.24 (jb51.net).rar download time may be a little long, please be patient;

4. After the download is complete, use the command: ll to view the current mysql-5.6.24.tar.gz file and then use the following command to decompress the compressed package: tar-zxvf mysql-5.6.14.tar.gz

5. Then use the command: ll to view the current mysql-5.6.24 directory. Use the command: cd mysql-5.6.24 to switch to the mysql-5.6.24 directory;

6. After completing the preceding steps, we will compile the mysql file. First, configure the compilation parameters and execute the following command:

Copy codeThe Code is as follows: cmake \-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \-DMYSQL_DATADIR =/usr/local/mysql/data \-DSYSCONFDIR =/etc \-region = 1 \-DWITH_INNOBASE_STORAGE_ENGINE = 1 \ -DWITH_MEMORY_STORAGE_ENGINE = 1 \-DWITH_READLINE = 1 \-DMYSQL_UNIX_ADDR =/var/lib/mysql. sock \-DMYSQL_TCP_PORT = 3306 \-DENABLED_LOCAL_INFILE = 1 \-character = 1 \-DEXTRA_CHARSETS = all \-DDEFAULT_CHARSET = utf8 \-DDEFAULT_COLLATION = utf8_general_ci

Then, you can use make & make install to compile and install mysql in two steps: Run make first, and then run make install. The entire process takes about 30 minutes, please be patient. You can do something else during this time.

7. After the installation is complete, we also need to create mysql configuration. First, set the mysql access permission, run the command to check whether there are mysql users and user groups, and view the user list command: cat/etc/passwd command: cat/etc/group

8. If it does not exist, create: Add User Group command: groupadd mysql Add User: useradd-g mysql then modify the user and user group to access the directory where the previously installed mysql is located and enter the command: chown-R mysql: mysql/usr/local/mysql

9. initialize the mysql configuration, switch to the mysql installation directory: cd/usr/local/mysql, and execute the initialization configuration script to create the built-in mysql System Database :. /scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql

10. Modify the mysql configuration file and enter the command: vi my. cnf then press the "insert" key on the keyboard, and then move the cursor to the row to be modified using the direction key of the keyboard. Add the following content: server-id = 1 report-port = 3306 port = 3306 datadir =/usr/local/mysql/datasocket =/var/lib/mysql. sock

This step is very important. You need to change the owner of the configuration file: chown-R mysql: mysql/usr/local/mysql/my. cnf; otherwise, an error will be reported when the mysql service is started below;

11. Add mysql to the startup Item and start the mysql service. (Note: when starting the MySQL service, my will be searched in certain order. cnf is first found in the/etc directory. If it cannot be found, it will be found in the mysql directory you installed. In this example, It is/usr/local/mysql/my. cnf. Note: After the minimal installation of CentOS 6.4 is completed, a my. cnf, You need to rename this file to another name, such as:/etc/my. cnf. bak. Otherwise, the file will interfere with the correct configuration of MySQL installed by source code, resulting in startup failure. The command for renaming is mv my. cnf my. cnf. bak) cp support-files/mysql. server/etc/init. d/mysqld # copy the script chmod + x/etc/init. d/mysqld # add executable permission chkconfig -- add mysqld # add to sysV service chkconfig mysqld on # start auto-start service mysqld start # start mysql service netstat-aux | grep mysq # view started mysql process

12. Add the mysql environment variable to facilitate future operations. Enter the password vi/etc/profile and add the following content at the bottom of the file: PATH =/usr/local/mysql/bin: $ PATHexport PATH: Save and exit. Enter the command to make the configuration take effect immediately: source/etc/profile

13. After installing mysql, the default root account is empty. Let's change the password and enter the command: mysql-uroot, press enter, and then enter the command: set password = PASSWORD ('20140901 ');

After setting, enter the command quit to exit the mysql environment;

14. After setting the mysql password, you must enter the following command to log on to mysql: Enter mysql-uroot-p and press Enter. A message will be displayed, prompting you to enter the password, after the statement is entered correctly and executed, a prompt line starting with mysql> is displayed. Here, you can enter any valid SQL query statement, for example, show databases; to display all databases, note that the semicolons that follow a line cannot be lost. It identifies the end of a line of commands.

Congratulations! mysql has been installed successfully.

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.