Install MySQL on 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. cnf rm-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.
After the preceding three steps, you can uninstall the old mysql version. When the new version of mysql is installed later, other legacy components will prompt incompatibility, and delete them one by one. 2. Install MySQL5.6 in the source code. Prerequisite 1: Since the source code is installed, you must first download the MySQL source code. We will not repeat the download as needed. Prerequisite 2: Install cmake. MySQL is compiled using cmake, so you need to install it in advance. This process is also very simple. After the above preparations are OK, the installation process is started. 2.1 compilation is the same as other projects on linux. MySQL compilation is also called make/make install. 2.1.1 run cmake in the code path:
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.
DMYSQL_DATADIR: MySQL data file location.
DSYSCONFDIR: Location of the MySQL configuration file. 2.1.2 make & make install .. At this point, the compilation process is complete. 2.2 Installation
# 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.cnf
The 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=3306
2.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 start
I 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 password
Enter the password twice. After changing the password, restart mysql. By now, MySQL has been upgraded from the old version.