Install MySQL[[email protected] Mysql] #tar –zxv–f mysql-5.6.16.tar.gz
[[email protected] Mysql] #cd mysql-5.6.16
[Email protected] mysql]# CMake. -dcmake_install_prefix=/usr/local/mysql/-dmysql_datadir=/usr/local/mysql/data-dwith_innobase_storage_engine=1- Dmysql_tcp_port=3306-dmysql_unix_addr=/usr/local/mysql/data/mysql.sock-dmysql_user=mysql-dwith_debug=0- Ddefault_charset=utf8-ddefault_collation=utf8_general_ci
Note: This command is one line
[[email protected] Mysql] #make
[[email protected] Mysql] #make Install
?
Parameter description:
-dcmake_install_prefix=/usr/local/mysql//installation directory
-dinstall_datadir=/usr/local/mysql/data//Database storage directory
-ddefault_charset=utf8//using UTF8 characters
-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local
?
Precautions:
When you recompile, you need to clear the old object file and cache information. Compile process can be intuitive to see the success of the compilation did not
# Make Clean
# rm-f CMakeCache.txt
# RM-RF/ETC/MY.CNF
?
Configuration
[Email protected] mysql]# Cd/usr/local/mysql
[Email protected] mysql]# chown-r root:mysql.
[Email protected] mysql]# chown-r mysql:mysql data
[[email protected] MySQL] #cp/opt/mysql/my.cnf/etc/my.cnf
[Email protected] mysql]# Cd/usr/local/mysql
[Email protected] mysql]# scripts/mysql_install_db--user=mysql
Setting environment variables
[Email protected] mysql]# Vi/root/.bash_profile
In path= $PATH: $HOME/bin add parameters as:
Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
Save changes
[Email protected] mysql]# Source/root/.bash_profile
?
Manually start MySQL
[email protected] localhost ~]# cd/usr/local/mysql
[[email protected] localhost mysql]#./bin/mysqld_safe--user=mysql &//start MySQL, but not stop
The boot log is written under this file:/usr/local/mysql/data/localhost.err
Turn off MySQL service
[[email protected] localhost mysql]# mysqladmin-u root-p shutdown//Here the root user of MySQL has not configured the password, so it is null. If you need to enter a password, just click Enter.
Another simple way to start MySQL (MySQL has been added to the system service)
[[email protected] localhost ~]# service mysql.server start
[[email protected] localhost ~]# service mysql.server stop
[email protected] localhost ~]# service mysql.server restart
If the above command appears: Mysql.server Unrecognized service
?
It is possible that MySQL has not been added to the system service, which is added in another way:
[[email protected] localhost mysql]# CP support-files/mysql.server/etc/init.d/mysql//Add MySQL startup service to system service
Note: The main is to copy Mysql.server to/etc/init.d, named MySQL. In some systems, Mysql.server is in/usr/local/mysql/share/mysql/mysql.server, and in this system, mysql.server in cd/usr/local/mysql/ The Support-files/mysql.server.
?
Then use #service MySQL start to start MySQL.
Modify MySQL Password
Optional step: Set Root password:/usr/local/mysql/bin/mysqladmin-u root password ' new-password '
/usr/local/mysql/bin/mysqladmin-u root-h localhost.localdomain password ' new-password '
This step requires the database to be started before it can be successfully executed)
?
The following is another way to modify the password for the root user of MySQL and to open a remote connection
[[email protected] rhel5~]# mysql-u root MySQL
Mysql>use MySQL;
Mysql>desc user;
Mysql> GRANT All privileges on * * to [email protected] '% ' identified by ' root '; The ability to add remote connections for root.
Mysql>update user Set Password = Password (' xxxxxx ') where user= ' root ';
Mysql>select Host,user,password from User where user= ' root ';
Mysql>flush privileges;
Mysql>exit
?
Re-login: Mysql-u root-p
?
If remote connections are not yet in progress, turn off the firewall
[[email protected] rhel5~]#/etc/rc.d/init.d/iptables stop
Copy Code
Note: If you cannot connect remotely, error MySQL error number 1130, then add the following statement to try:
?
Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' ****** ' with GRANT OPTION;
?
?