MySQL Database-source installationTags: mysql
One: Uninstall the old version
Use the following command to check if MySQL Server is installed
Rpm-qa | grep MySQL
Some words are unloaded by the following command
RPM-E MySQL//normal Delete mode
Rpm-e–nodeps MySQL//brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted
Second, install the tools needed to compile MySQL
1) Installing g++ and GDB
Yum Install gcc-c++
Yum Install GDB
2) Install CMake
Yum Install CMake
3) Install ncurses
Yum Install Ncurses-devel
4) Install Bison
Yum Install Bison bison-devel
5) Compile Dependent tool description please refer to http://dev.mysql.com/doc/refman/5.6/en/source-installation.html
Third, install MySQL
1) Refer to the following two links to download MySQL 5.6.26
Http://dev.mysql.com/doc/refman/5.6/en/getting-mysql.html
Http://dev.mysql.com/downloads/mirrors.html
Unzip after download is complete
Tar xvf mysql-5.6.26.tar.gz
CD mysql-5.6.26
2) Compile and install
Copy Code
CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/usr/local/mysql/data \
-DSYSCONFDIR=/ETC \
-dwith_innobase_storage_engine=1 \
-dwith_partition_storage_engine=1 \
-dmysql_unix_addr=/tmp/mysql.sock \
-dmysql_tcp_port=3306 \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci
Make
Make install
Copy Code
The compilation process takes about 30 minutes, and you can see the results after compiling and installing.
Ll/usr/local/mysql
Iv. Configuring MySQL
1) Configure the user
Use the following command to see if there are MySQL users and user groups
CAT/ETC/PASSWD View the list of users
Cat/etc/group viewing a list of user groups
If not, create
Groupadd mysqluseradd-r-G MySQL MySQL
Confirm the creation result
ID MySQL
Modify/usr/local/mysql Directory Permissions
Chown-r Mysql:mysql/usr/local/mysql
2) Initialize the configuration
Install Perl required to run the MySQL test script
Yum Install Perl
Go to installation path
Cd/usr/local/mysql
Execute the initialization configuration script to create the system's own database and table
Scripts/mysql_install_db–basedir=/usr/local/mysql–datadir=/usr/local/mysql/data–user=mysql
Note: When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory, find will search "$basedir/my.cnf", in this case is/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file!
Note: After the minimum installation of the CentOS version 6.4 operating system, there will be a my.cnf in the/etc directory, which will need to be renamed to a different name, such as:/etc/ My.cnf.bak, otherwise, the file will interfere with the correct configuration of the source installed MySQL, resulting in the inability to start.
After updating the system with Yum Update, you need to check if there is a my.cnf in the/etc directory, and if so, rename it to something else. Otherwise, MySQL will start with this configuration file, which may cause problems such as an inability to start properly.
3) Start MySQL
Add services, Copy service scripts to the INIT.D directory, and set boot boot
CP Support-files/mysql.server/etc/init.d/mysql
Chkconfig MySQL on
Service MySQL start– start MySQL
4) Configure the MySQL account password
After MySQL starts successfully, Root does not have a password, we need to set the root password.
Before setting, we need to set path, or we can't call MySQL directly
Modify the/etc/profile file to add at the end of the file
Path=/usr/local/mysql/bin: $PATH
Export PATH
Close the file, run the following command, and let the configuration take effect immediately
Source/etc/profile
Now, we can enter MySQL in the terminal directly into the MySQL environment
Execute the following command to modify the root password
Mysql-uroot
mysql> SET PASSWORD = PASSWORD (' 123456 ');
To set the root user to have remote access, perform
Mysql> GRANT all privileges on . To ' root ' @ '% ' identified by ' 123456 ' with GRANT OPTION;
The password at remote access can be different from local.
5) Configure the firewall
Firewall 3306 port is not enabled by default, to remote access, you need to open this port
Open/etc/sysconfig/iptables
Under "-A input–m state–state new–m tcp–p–dport 22–j ACCEPT", add:
-A input-m state–state new-m tcp-p-dport 3306-j ACCEPT
Then save and close the file, run the following command in the terminal and refresh the firewall configuration:
Service Iptables Restart
With everything configured, you'll be able to access MySQL.
Source installation MySQL