Linux Installing MySQL 5.6. 24 Using Text Instructions

  • 2021-07-01 08:22:56
  • OfStack

Linux Installing MySQL Notes

1. Before installing the MySQL database server, make sure that your linux system can be connected to the network. Next, we will install mysql by source code. First, log in to your Linux system through putty, and make sure that the compiled environments such as gcc c + + have been installed in the system, because mysql has been compiled with cmake since version 5.5. If none of the three environments are installed, you can use the following commands to install: yum-y install make gcc-c + + cmake bison-devel ncurses-devel

2. Find whether the relevant components of mysql database have been installed in the system. Use the command: rpm-qa grep mysql to find out. If found, you can use the following command to forcibly uninstall: rpm-e package name

If you used the default installation options when installing Linux system, this step can be skipped;

3. Then let's download the source installation package of mysql, and use the following command to download wget http://xiazai.ofstack.com/201701/yuanma/mysql5.6. 24 (ofstack.com). rar may take a little long to download, please be patient;

4. After downloading, use the command: ll to view the current mysql-5. 6.24. tar. gz file and then use the following command to extract the compressed package: tar-zxvf mysql-5. 6.14. tar. gz

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

6. After the above steps are completed, let's start compiling mysql files. First, configure the relevant parameters of compilation and execute the following commands:

cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci

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

7. After the installation, we need to establish the configuration of mysql. First, set the access authority of mysql, use the command to check whether mysql users and user groups already exist, and check the user list command: cat/etc/passwd Check the user group list command: cat/etc/group

8. If it does not exist, we will create: Add User Group Command: groupadd mysql Add User: useradd-g mysql mysql and then modify the access user and user group input command: chown-R mysql: mysql/usr/local/mysql

9, then initialize the mysql configuration, switch to the mysql installation directory: cd/usr/local/mysql, execute the initialization configuration script, and create the system database that comes with mysql:. /scripts/mysql_install_db-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-user=mysql

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

This step is important and requires changing the owner of the configuration file: chown-R mysql: mysql/usr/local/mysql/my. cnf otherwise starting the mysql service below will report an error;

11. Add mysql to the startup entry and start the mysql service (Note: When starting MySQL service, we will search for my. cnf in the order of 1, first look in the/etc directory, and if we can't find it, we will look in the mysql directory you installed. In this example, the/usr/local/mysql/my. cnf. Note: One my. cnf may exist in the/etc directory after the minimum installation of the CentOS version 6.4 is complete. This file needs to be renamed to another name, such as:/etc/my. cnf. bak, otherwise it will interfere with the correct configuration of the source installed MySQL and cause it to fail to start. The command to rename is: mv my. cnf my. cnf. bak) cp support-files/mysql. server/etc/init. d/mysqld # Copy Script chmod + x/etc/init. d/mysqld # Add Executable Permissions chkconfig--ES216mysqld # Add to sysV Service chkconfig mysqld on # Startup Self-N service netstat-auxgrep mysq # View started mysql process

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

13. For the installed mysql, the default root account is empty. Let's modify the password input command: mysql-uroot Enter, and then enter the command: SET PASSWORD = PASSWORD ('123456');

After setting, enter the command: quit;; Exit the mysql environment;

14. After setting the password of mysql, you need to enter the following commands to log in to mysql correctly: Enter the command: mysql-uroot-p, you will be prompted to enter the password. After entering correctly and executing, you will see mysql > At the beginning of the prompt line, where you can enter any valid sql query statement: for example: show databases; To display all databases, note that the semicolon that follows cannot be lost, which identifies the end of the 1-line command.

At this point, congratulations, the installation of mysql was successful.


Related articles: