1. Build MySQL Account
First log on to Linux as root, and then execute the following command to create the MySQL group and user
[[email protected] home]# groupadd MySQL [[email protected] home]# useradd-s/sbin/nologin-g mysql-m MySQL [email pr Otected] home]# tail-1/etc/passwd feitian:x:811:811::/home/mysql:/sbin/nologin (/sbin/nologin indicates that you cannot log in)-s/sbin/ Nologin Disables login-gmysql specifies that the MySQL group-M is not creating home directories. [Email protected] tools]# cd/home/loveyu/tools/
2. Compile and install MySQL
2.1 Getting MySQL Software
1 "Upload via RZ
2 "Wgte in the mirror site of Sohu download http://mirrors.sohu.com/mysql/MySQL-5.7/
2.2 compilation [[email protected] tools]# tar zxf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
./configure \ --prefix=/usr/local/mysql \ #安装路径--with-unix-socket-path=/usr/local/ mysql/tmp/mysql.sock \ #指定socket文件存放--localstatedir=/usr/local/mysql/data \ # MySQL data file storage location--enable-assembler \ #允许使用汇编模式--enable-thread-safe-client -- with-mysqld-user=mysql \ #指定MySQL运行的系统用户--with-big-tables--without-debug \ #使用非debug--with-pthread \ # Forcing a pthread-line library to be used to compile--enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase,partition -- enable-thread-safe-client \ #使用线程的方式编译客户端--with-client-ldflags=-all-static \ #服务端使用静态库--with-mysqld-ldflags=-all-static #客户端使用静态库 # Make && after waiting to finish; make install
3. Get MySQL configuration file
[[email protected] mysql-5.1.72]# ll support-files/*. cnf-rw-r--r-- 1 root root 4714 may 11 08:53 support-files/ my-huge.cnf-rw-r--r-- 1 root root 19763 may 11 08:53 support-files/ my-innodb-heavy-4g.cnf-rw-r--r-- 1 root root 4688 may 11 08:53 support-files/my-large.cnf-rw-r--r-- 1 root root 4699 may 11 08:53 support-files/my-medium.cnf-rw-r--r-- 1 root root 2467 May 11 08:53 support-files/my-small.cnf# here are large small and large three configuration files, here is the test environment we'd better choose the smallest configuration file [[email protected] Mysql-5.1.72]# /bin/cp support-files/my-innodb-heavy-4g.cnf /etc/my.cnf[[email protected] mysql-5.1.72]# ls -l /etc/my.cnf -rw-r--r-- 1 root root 19763 may 11 09:02 /etc/my.cNf
4. Initialize database, create MySQL database file
[[email protected] data]# mkdir/usr/lacal/mysql/data-p[[email protected] data]# chown-r Mysql/usr/local/mysql[[email p Rotected] tools]#/application/mysql/scripts/mysql_install_db basedir=/application/mysql--datadir=/application/ Mysql/data--user=mysql
5. Start the database
[[email protected] mysql-5.1.72]# cp support-files/ mysql.server /usr/local/mysql/bin/[[email protected] mysql-5.1.72]# chmod 700 / usr/local/mysql/bin/mysql.server [[email protected] tools]# /usr/local/mysql/bin/ Mysql.server startstarting mysql. success! [[email protected] tools]# ps -ef|grep 3306root 64252 63576 0 09:48 pts/0 00:00:00 grep 3306[[email protected] mysql-test]# /usr/ local/mysql/bin/mysqld_safe &[1] 64731[[email protected] mysql]# 170511 11:50:09 mysqld_safe logging to '/var/log/mysqld.log '. 170511 11:50:09 mysqld_ Safe starting mysqld daemon with databases from /var/lib/mysql
6. Configure MySQL command global use path (/etc/profile)
Path= $PATH:/usr/bin/mysql
7, configuration/etc/init.d/mysqld start the way the database
[[email protected] mysql-5.1.72]# CP Support-files/mysql.server/etc/init.d/mysqld[[email protected] mysql-5.1.72]# chmod 700/etc/init.d/mysqld[[email protected] mysql-5.1.72]#/etc/init.d/mysqld restartshutting down MySQL ..... success! Starting MySQL. success!
8. Set the boot start
[Email protected] mysql-5.1.72]# chkconfig--add mysqld[[email protected] mysql-5.1.72]# chkconfig mysqld On or into the rc.local
9. Log in to MySQL database test
9.1 Add password to root
[Email protected] mysql-5.1.72]# mysqladmin-u root password ' fenghui ' [[email protected] mysql-5.1.72]# Mysqlerror 1045 ( 28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
9.2 Removing redundant users
mysql> select user,host from mysql.user;+------+-----------+|user | host |+------+-----------+|root | 127.0.0.1| | | feitian | | root | feitian | | | localhost| | root | localhost|+------+-----------+5 rows in set (0.00 sec) mysql> drop user "" @localhost; query ok, 0 rows affected (0.00 sec) mysql> drop user "" @ Feitian; query ok, 0 rows affected (0.00 sec) mysql> drop user [email protected]; query ok, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user;+------+-----------+|user | host |+------+-----------+|root |127.0.0.1 | | root | localhost|+------+-----------+2 rows in set (0.00 sec) if the userIf the name also has capital letters, delete the delete from mysql.user while user= "" and host= "uppercase username" with the following command
Error Summary: If the following error occurred when starting the database, you can generally reinitialize the data file and delete all the data files.
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
This article is from the "13122323" blog, please be sure to keep this source http://13132323.blog.51cto.com/13122323/1952012
MySQL 5.5 Single-instance compilation installation