Install MySQL in linux source code
Recently, MySQL Fabric needs to be used. This product is a utility generated after MySQL5.6.10. MySQL5.1 is installed on the machine at hand. Therefore, you need to upgrade the old MySQL version to MySQL 5.6 first. I have never played MySQL before, so I have to pay a little fee this time. Here, we will record the process and hope to provide some help to those who need it. Next we will officially start.1. Deleting an old version of MySQL is actually a simple task, but it is also slow because of worries that the dependencies of various packages may cause various problems. In fact, you only need to do this step: 1.1 view and delete the installed mysql version
View the installed mysql version: rpm-qa | grep-I mysql
You only need to uninstall the two rpm packages of the client/server. During the process, you may be prompted about the dependency of a package, and add -- nodeps.1.2 Delete the data file/etc/my. cnf and the data file under the installation directory/usr/local/mysql/(this directory is specified during installation. Rm-r/etc/my. cnfrm-rf/usr/local/mysql1.3 check whether mysql is often ignored during running. If yes, kill it. Run the following command: ps-fe | grep mysql.
cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STO…The preceding compilation parameters need to be used in subsequent installation. Others can be copied directly. DCMAKE_INSTALL_PREFIX: the installation path of MySQL. After installation, it is the working path of MySQL.
# cd /usr/local/mysql# chown -R mysql:mysql .# chown -R mysql:mysql ./data# scripts/mysql_install_db --defaults-file=/etc/my.cnf# cp support-files/my-default.cnf /etc/my.cnfThe above are all MySQL configuration processes, and the path must be consistent with the above cmake parameter. Note the mysql configuration file/etc/my. cnf. The following is my configuration file, which is basically maintained.
[mysql]socket = /tmp/mysqld.sock[mysqld]user = mysqldatadir = /usr/local/mysql/dataport=33062.3 There are three ways to start MySQL:
Method 1: # bin/mysqld_safe -- defaults-file =/etc/my. cnf method 2: # bin/mysqld method 3: cp support-files/msql. server/etc/init. d/mysqlservice mysql startI believe you are more familiar with the third method. You can use start, restart, or stop to start, restart, or stop a service, which is widely used in linux. I am also used to this method, but I found a situation during use. When using service mysql start, if the service fails to start, there is basically no error log output, so it is difficult to determine the cause of the startup failure. At this time, we recommend that you use method 2 to start it. It will output the cause of the error, which is much easier to find.Check whether startup is successful: ps-ef | grep mysql2.4 change root Password
# ./bin/mysqladmin -u root passwordEnter the password twice. After changing the password, restart mysql. By now, MySQL has been upgraded from the old version.
The following is the configuration experience of CentOS Linux 5:
Add a mysql account
Installation is required before compilation.
Cmake-2.8.4 and bison-2.4.3
Decompress mysql-5.5.15.tar.gz after successful installation:
Open the terminal in the source code root directory and enter the following configuration parameters and press Enter.
Cmake-DCMAKE_INSTALL_PREFIX =/etc/mysql \
-DMYSQL_UNIX_ADDR =/etc/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/var/mysql/data \
-DMYSQL_USER = mysql
After successfully executing the following command, you will be able to see it at the end (/root/Desktop/is your source code directory, depending on your situation)
-- Build files have been written to:/root/Desktop/mysql-5.5.15
Run make to install:
The following steps are not described in detail:
Chown-R mysql: mysql.
Scripts/mysql_install_db -- user = mysql
Chown-R mysql data
Cp support-files/mysql. server mysql; chmod + x mysql
Chown-R mysql: root.
./Bin/mysqladmin-u root-p 123456
Add startup Service
Chkconfig -- add mysql
Chkconfig mysql on
Service mysql start
If everything goes well, it will be done here. I wish you success.
Why should I create a mysql user first when installing mysql using the source code in linux?
For security .. The advantage of doing so is that when someone else gets rid of your database, you can only get the mysql permission of the system, but not the entire root permission .. .. It is much safer .. Not only does mysql, such as apache, and many other software have such settings .. It indicates that such software is good software ..