MySQL 5.5.37 compilation and Installation Details
Today we will introduce you to the MySQL 5.5.37 compilation and installation method, which is also a common method in our work. We hope that through the introduction of this article, we can provide you with an installation idea!
1. Create a mysql installation directory and user
Mkdir-p/usr/local/mysql # Install mysql
Mkdir-p/usr/local/mysql/data # store the database
Groupadd mysql
Useradd-r-g mysql
Ii. Install the dependency library in yum
Yum install gcc-c ++ ncurses-devel-y
# Installation error message:
CMake Error atcmake/readlineNaNake: 83 (MESSAGE ):
Curses library notfound. Please install appropriatepackage,
# Solution
Yum install ncurses-devel
Rm CMakeCache.txt
Iii. Compile and install cmake
Tar-zxv-f cmake-2.8.10.2.tar.gz
Cd cmake-2.8.10.2
./Configure
Make & make install
Iv. Compile and install mysql5.5.37
Tar-zxv-f mysql-5.5.37.tar.gz # unzip
Cd mysql-5.5.37
# Compile Parameters
[Root @ localhost mysql-5.5.37] #
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/usr/local/mysql/data \
-DMYSQL_USER = mysql \
-DMYSQL_TCP_PORT = 3306
# Execute the make command
Make
Make install
5. Check whether the installation is successful
Cd/usr/local/mysql/
[Root @ localhost mysql] # ls
Bin COPYING data docs include INSTALL-BINARY lib man mysql-test README scripts share SQL-plugin support-files
# If you have bin and other files, congratulations on your successful installation of mysql.
6. Detailed steps for configuring mysql5.5.37
# Set the owner of all files in the current directory to root and the group to mysql
Chown-R root: mysql.
Chown-R mysql: mysql data (optional)
# Add the mysql startup service to the System Service
[Root @ localhost mysql] # cp support-files/my-medium.cnf/etc/my. cnf
Cp: overwrite "/etc/my. cnf "? Y
# Mysql startup error Solution
1. Problems
[Root @ localhost mysql] #/etc/rc. d/init. d/mysql statusMySQL is not running, but lock file (/var/lock/subsys/mysql [FAILED] [root @ localhost mysql] #/etc/rc. d/init. d/mysql startStarting MySQL... the server quit without updating PID file (/usr/local/mysql/data/localhost. localdomain. pid ). [FAILED]
2. Cause
No permission table for initialization
3. Solution
Cd/usr/local/mysql (enter the mysql installation directory) chown-R mysql. mysql.
# Reinitializing a database
[Root @ B2C-test-server mysql] #./scripts/mysql_install_db -- user = mysql
[Root @ B2C-test-server mysql] #/etc/init. d/mysql start
Starting MySQL... SUCCESS!
# An error occurred while directly entering mysql to start the database:
[Root @ localhost mysql] # mysql
-Bash: mysql: command not found
# Solution
[Root @ localhost mysql] # ln-s/usr/local/mysql/bin/mysql/usr/bin/
# Modifying the password of the root user of MySQL and opening a remote connection
[Root @ B2C-test-server mysql] # mysql-u root mysql
Mysql> use mysql;
Mysql> desc user;
Mysql> grant all privileges on *. * TO root @ "%" identified by "root"; # add remote connection capability TO root
Mysql> update user set Password = password ('000000') where User = 'root'; # set the root user Password
Mysql> select Host, User, Password from user where User = 'root ';
Mysql> flush privileges;
Mysql> exit
# Log on again
[Root @ B2C-test-server mysql] # mysql-u root-p
Enter password: 123456
# Disable the firewall if remote connection is not available
[Root @ B2C-test-server mysql] #/etc/rc. d/init. d/iptables stop
VII. Set the mysql password
# Method 1: Use mysqladmin outside the mysql System
[Root @ B2C-test-server mysql] # mysqladmin-u rootflush-privileges password 'root'
# Method 1: log on to the mysql System
[Root @ B2C-test-server mysql] # mysql-u root-p
Enter password:
Mysql> use mysql;
Database changed
Mysql> update user set password = password ("root") where user = 'root ';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
Mysql> flush privileges;
Mysql> exit;
8. How can I forget the Mysql root Password?
# Method 1:
#/Etc/init. d/mysqld stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-uroot mysql
Mysql> update user setPassword = Password ('newpassword') where User = 'root ';
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysql restart
# Mysql-uroot-penter password:
# Method 2:
# Modify MySQL Logon Settings:
# Add the following sentence to the [mysqld] section: skip-grant-tables
As follows:
[Root @ B2C-test-server mysql] # vi/etc/my. cnf
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
User = mysql
Skip-grant-tables
# Restart mysql
/Etc/init. d/mysqld restartStoppingmysqld:
[OK] Startingmysqld: [OK]
# Logon without a password:
# Mysql
Mysql> use mysql; update user setPassword = Password ('root') where User = 'root'; mysql> flush privileges;
# Exit, modify/etc/my. conf, delete skip-grant-tables, and restart mysql. Done
OK! Mysql compilation and installation will be introduced here today!
-------------------------------------- Split line --------------------------------------
Install MySQL in Ubuntu 14.04
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
MySQL-5.5.38 universal binary Installation
-------------------------------------- Split line --------------------------------------
This article permanently updates the link address: