1.确认以下依赖包已安装
【ncurses ncurses-devel openssl-devel bison autoconf automake bison gcc m4 libtool make gcc-c++ cmake perl】
[root@std ~]# rpm -qa|grep ncurses ncurses-5.5-24.20060715 ncurses-devel-5.5-24.20060715 [root@std ~]# rpm -qa|grep openssl openssl-0.9.8e-12.el5_4.6 openssl-devel-0.9.8e-12.el5_4.6 [root@std ~]# rpm -qa|grep bison bison-2.3-2.1 [root@std ~]# rpm -qa|grep autoconf autoconf-2.59-12 [root@std ~]# rpm -qa|grep automake automake14-1.4p6-13.el5.1 automake15-1.5-16.el5.2 automake-1.9.6-2.3.el5 automake16-1.6.3-8.el5.1 automake17-1.7.9-7.el5.2 [root@std ~]# rpm -qa|grep gcc compat-libgcc-296-2.96-138 compat-gcc-34-g77-3.4.6-4 libgcc-4.1.2-48.el5 gcc-c++-4.1.2-48.el5 compat-gcc-34-3.4.6-4 compat-gcc-34-c++-3.4.6-4 gcc-java-4.1.2-48.el5 gcc-4.1.2-48.el5 gcc-gfortran-4.1.2-48.el5 [root@std ~]# rpm -qa|grep m4 m4-1.4.5-3.el5.1 [root@std ~]# rpm -qa|grep libtool libtool-1.5.22-7.el5_4 [root@std ~]# rpm -qa|grep make automake14-1.4p6-13.el5.1 automake15-1.5-16.el5.2 automake-1.9.6-2.3.el5 imake-1.0.2-3 make-3.81-3.el5 automake16-1.6.3-8.el5.1 automake17-1.7.9-7.el5.2 [root@std ~]# rpm -qa|grep gcc-c++ gcc-c++-4.1.2-48.el5
2.建立用户及组
[root@std ~]# groupadd mysql [root@std ~]# useradd -r -g mysql -s /bin/false mysql [root@std ~]#
3.解压mysql包并建立软连接
[root@std ~]# cp mysql-5.7.10-linux-glibc2.5-i686.tar.gz /usr/local/ [root@std ~]# cd /usr/local/ [root@std local]# tar -xzf mysql-5.7.10-linux-glibc2.5-i686.tar.gz [root@std local]# ls -ld mysql-5.7.10-linux-glibc2.5-i686* drwxr-xr-x 9 7161 wheel 4096 Nov 30 04:47 mysql-5.7.10-linux-glibc2.5-i686 -rw-r--r-- 1 root root 584116380 Feb 4 10:17 mysql-5.7.10-linux-glibc2.5-i686.tar.gz [root@std local]# ln -s mysql-5.7.10-linux-glibc2.5-i686 mysql [root@std local]# ls -ld mysql* lrwxrwxrwx 1 root root 32 Feb 4 10:29 mysql -> mysql-5.7.10-linux-glibc2.5-i686 drwxr-xr-x 9 7161 wheel 4096 Nov 30 04:47 mysql-5.7.10-linux-glibc2.5-i686 -rw-r--r-- 1 root root 584116380 Feb 4 10:17 mysql-5.7.10-linux-glibc2.5-i686.tar.gz
4.配置mysql
[root@std local]# cd mysql [root@std mysql]# mkdir {data,log} [root@std mysql]# ls -d data data [root@std mysql]# ls -d log log [root@std mysql]# cd .. [root@std local]# ll -d mysql lrwxrwxrwx 1 root root 32 Feb 4 10:29 mysql -> mysql-5.7.10-linux-glibc2.5-i686 [root@std local]# chown -R mysql.mysql mysql [root@std local]# ll -d mysql lrwxrwxrwx 1 mysql mysql 32 Feb 4 10:29 mysql -> mysql-5.7.10-linux-glibc2.5-i686 [root@std local]# ll -d mysql-5.7.10-linux-glibc2.5-i686 drwxr-xr-x 11 7161 wheel 4096 Feb 4 10:31 mysql-5.7.10-linux-glibc2.5-i686 [root@std local]# chown -R mysql.mysql mysql-5.7.10-linux-glibc2.5-i686 [root@std local]# ll -d mysql-5.7.10-linux-glibc2.5-i686 drwxr-xr-x 11 mysql mysql 4096 Feb 4 10:31 mysql-5.7.10-linux-glibc2.5-i686
[root@std local]# cp mysql/support-files/my-default.cnf /etc/my.cnf [root@std local]# vi /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # socket = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [client] default-character-set = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock [mysqld] character-set-server = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock skip-name-resolve basedir = /usr/local/mysql datadir = /usr/local/mysql/data log-error = /usr/local/mysql/log/mysql_error.log pid-file =/usr/local/mysql/log/mysql.pid explicit_defaults_for_timestamp=true lower_case_table_names = 1 query_cache_limit = 10M max_heap_table_size = 64M ~ ~ ~ "/etc/my.cnf" 50L, 1582C written
5.初始化数据库
[root@std local]# /usr/local/mysql/bin/mysql_install_db > --user=mysql > --basedir=/usr/local/mysql > --datadir=/usr/local/mysql/data 2016-02-04 10:55:58 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
发现有报错,提示:MySQL 5.7.6 以上的版本使用mysqld --initialize进行初始化
[root@std local]# /usr/local/mysql/bin/mysqld > --initialize > --user=mysql > --basedir=/usr/local/mysql > --datadir=/usr/local/mysql/data 2016-02-04T02:59:41.907629Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2016-02-04T02:59:41.907698Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 2016-02-04T02:59:41.910476Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-02-04T02:59:41.910635Z 0 [ERROR] Aborting
发现有些启动参数必须设置:参考 http://blog.csdn.net/wyzxg/article/details/8787878
提示data directory has files,即数据目录已经有文件了,清除数据目录里的文件
配置sql_mode:
[root@std data]# vi /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # socket = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M [client] default-character-set = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock [mysqld] character-set-server = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock skip-name-resolve basedir = /usr/local/mysql datadir = /usr/local/mysql/data log-error = /usr/local/mysql/log/mysql_error.log pid-file =/usr/local/mysql/log/mysql.pid explicit_defaults_for_timestamp=true lower_case_table_names = 1 query_cache_limit = 10M max_heap_table_size = 64M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER ~ ~ "/etc/my.cnf" 50L, 1657C written
[root@std local]# pwd /usr/local [root@std local]# cd mysql/data/ [root@std data]# ls auto.cnf ca.pem client-cert.pem client-req.pem ibdata1 ib_logfile1 performance_schema server-key.pem sys ca-key.pem ca-req.pem client-key.pem ib_buffer_pool ib_logfile0 mysql server-cert.pem server-req.pem [root@std data]# rm -rf * [root@std data]# ll total 0
重新初始化:
[root@std local]# /usr/local/mysql/bin/mysqld > --initialize > --user=mysql > --basedir=/usr/local/mysql > --datadir=/usr/local/mysql/data 2016-02-04T03:27:21.900630Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-02-04T03:27:21.900825Z 0 [ERROR] Aborting
发现还是提示同样的报错,删除之前建的data文件夹,由mysql自己创建data目录即可。
[root@std mysql]# ls bin COPYING data docs include INSTALL-BINARY lib log man README share support-files [root@std mysql]# rm -rf data [root@std mysql]# ll data ls: data: No such file or directory
在重新初始化,没有任何提示,正常结束:
[root@std mysql]# /usr/local/mysql/bin/mysqld > --initialize > --user=mysql > --basedir=/usr/local/mysql > --datadir=/usr/local/mysql/data [root@std mysql]#
[root@std mysql]# /usr/local/mysql/bin/mysql_ssl_rsa_setup
Generating a 2048 bit RSA private key ....................+++ ....................+++ writing new private key to 'ca-key.pem' ----- Generating a 2048 bit RSA private key ...............................................................+++ ..+++ writing new private key to 'server-key.pem' ----- Generating a 2048 bit RSA private key ......+++ .............................................................+++ writing new private key to 'client-key.pem' -----
6.启动数据库
[root@std mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql 160204 12:27:53 mysqld_safe Logging to '/usr/local/mysql/log/mysql_error.log'. 160204 12:27:53 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
修改密码发现有权限问题:
[root@std data]# /usr/local/mysql/bin/mysqladmin -u root password '123456' mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
在mysql_error.log 日志里发现有初始密码:
[root@std log]# tail -f mysql_error.log 2016-02-04T03:53:14.628582Z 0 [Warning] InnoDB: New log files created, LSN=45790 2016-02-04T03:53:15.260581Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-02-04T03:53:15.382168Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d1b4565b-caf2-11e5-a1fe-000c29a3d3fb. 2016-02-04T03:53:15.463227Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2016-02-04T03:53:15.465781Z 1 [Note] A temporary password is generated for root@localhost: F>nWo%wli60_ 2016-02-04T03:53:29.091095Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
使用初始密码登录,发现登录不了:
[root@std ~]# /usr/local/mysql/bin/mysql -u root -p 'F>nWo%wli60_' Enter password:
7.利用–skip-grant-tables的方式登录数据库服务器
--kill掉mysql服务
[root@std bin]# ps -ef|grep mysql |grep -v grep root 10546 8761 0 11:53 pts/3 00:00:00 tail -f mysql_error.log root 11188 5781 0 12:27 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql mysql 11430 11188 0 12:27 pts/2 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/log/mysql_error.log --pid-file=/usr/local/mysql/log/mysql.pid --socket=/usr/local/mysql/mysql.sock --port=3306 [root@std bin]# kill -9 11188 [root@std bin]# kill -9 11430 [root@std bin]# ps -ef|grep mysql |grep -v grep root 10546 8761 0 11:53 pts/3 00:00:00 tail -f mysql_error.log
[root@std mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql 160204 12:27:53 mysqld_safe Logging to '/usr/local/mysql/log/mysql_error.log'. 160204 12:27:53 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data Killed [root@std mysql]#
--修改my.cnf配置文件,增加skip-grant-tables配置
[root@std mysql]# vi /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # socket = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M [client] default-character-set = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock [mysqld] character-set-server = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock skip-name-resolve basedir = /usr/local/mysql datadir = /usr/local/mysql/data log-error = /usr/local/mysql/log/mysql_error.log pid-file =/usr/local/mysql/log/mysql.pid explicit_defaults_for_timestamp=true lower_case_table_names = 1 query_cache_limit = 10M max_heap_table_size = 64M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER skip-grant-tables "/etc/my.cnf" 51L, 1675C written
--启动mysql服务
[root@std mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql 160204 12:47:05 mysqld_safe Logging to '/usr/local/mysql/log/mysql_error.log'. 160204 12:47:05 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
--登录mysql服务,修改root密码
[root@std bin]# /usr/local/mysql/bin/mysql -u root -p Enter password: --直接回车 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 3 Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root'; ERROR 1054 (42S22): Unknown column 'password' in 'field list'
发现此处修改密码出错,该版本中user表已经没有password列:
mysql> desc user ; +------------------------+-----------------------------------+------+-----+-----------------------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+-----------------------------------+------+-----+-----------------------+-------+ | Host | char(60) | NO | PRI | | | | User | char(32) | NO | PRI | | | | Select_priv | enum('N','Y') | NO | | N | | | Insert_priv | enum('N','Y') | NO | | N | | | Update_priv | enum('N','Y') | NO | | N | | | Delete_priv | enum('N','Y') | NO | | N | | | Create_priv | enum('N','Y') | NO | | N | | | Drop_priv | enum('N','Y') | NO | | N | | | Reload_priv | enum('N','Y') | NO | | N | | | Shutdown_priv | enum('N','Y') | NO | | N | | | Process_priv | enum('N','Y') | NO | | N | | | File_priv | enum('N','Y') | NO | | N | | | Grant_priv | enum('N','Y') | NO | | N | | | References_priv | enum('N','Y') | NO | | N | | | Index_priv | enum('N','Y') | NO | | N | | | Alter_priv | enum('N','Y') | NO | | N | | | Show_db_priv | enum('N','Y') | NO | | N | | | Super_priv | enum('N','Y') | NO | | N | | | Create_tmp_table_priv | enum('N','Y') | NO | | N | | | Lock_tables_priv | enum('N','Y') | NO | | N | | | Execute_priv | enum('N','Y') | NO | | N | | | Repl_slave_priv | enum('N','Y') | NO | | N | | | Repl_client_priv | enum('N','Y') | NO | | N | | | Create_view_priv | enum('N','Y') | NO | | N | | | Show_view_priv | enum('N','Y') | NO | | N | | | Create_routine_priv | enum('N','Y') | NO | | N | | | Alter_routine_priv | enum('N','Y') | NO | | N | | | Create_user_priv | enum('N','Y') | NO | | N | | | Event_priv | enum('N','Y') | NO | | N | | | Trigger_priv | enum('N','Y') | NO | | N | | | Create_tablespace_priv | enum('N','Y') | NO | | N | | | ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | | | ssl_cipher | blob | NO | | NULL | | | x509_issuer | blob | NO | | NULL | | | x509_subject | blob | NO | | NULL | | | max_questions | int(11) unsigned | NO | | 0 | | | max_updates | int(11) unsigned | NO | | 0 | | | max_connections | int(11) unsigned | NO | | 0 | | | max_user_connections | int(11) unsigned | NO | | 0 | | | plugin | char(64) | NO | | mysql_native_password | | | authentication_string | text | YES | | NULL | | | password_expired | enum('N','Y') | NO | | N | | | password_last_changed | timestamp | YES | | NULL | | | password_lifetime | smallint(5) unsigned | YES | | NULL | | | account_locked | enum('N','Y') | NO | | N | | +------------------------+-----------------------------------+------+-----+-----------------------+-------+ 45 rows in set (0.01 sec)
使用下面的语句修改密码:
mysql> update user set authentication_string=password('123456'), password_expired='N' where user='root'; Query OK, 1 row affected, 1 warning (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>
--关闭mysql服务,去掉skip-grant-tables
[root@std bin]# /usr/local/mysql/bin/mysqladmin -u root -p shutdown Enter password: [root@std bin]# ps -ef|grep mysql|grep -v grep root 10546 8761 0 11:53 pts/3 00:00:00 tail -f mysql_error.log
[root@std mysql]# vi /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # socket = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M [client] default-character-set = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock [mysqld] character-set-server = utf8 port = 3306 socket = /usr/local/mysql/mysql.sock skip-name-resolve basedir = /usr/local/mysql datadir = /usr/local/mysql/data log-error = /usr/local/mysql/log/mysql_error.log pid-file =/usr/local/mysql/log/mysql.pid explicit_defaults_for_timestamp=true lower_case_table_names = 1 query_cache_limit = 10M max_heap_table_size = 64M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER ~ "/etc/my.cnf" 50L, 1657C written
--重新启动mysql服务,用新密码尝试登录
[root@std bin]# ./mysql -u root -p Enter password: --此时不输入密码回车 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@std bin]# ./mysql -u root -p Enter password: --输入新密码 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
--尝试启动时加上skip-grant-tables参数无密码登录
-1-关闭数据库
[root@std bin]# ./mysqladmin -u root -p shutdown Enter password: [root@std bin]# ps -ef|grep mysql|grep -v grep root 10546 8761 0 11:53 pts/3 00:00:00 tail -f mysql_error.log
-2-加上skip-grant-tables方式启动
[root@std mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables 160204 13:19:21 mysqld_safe Logging to '/usr/local/mysql/log/mysql_error.log'. 160204 13:19:21 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
-3-尝试无密码登录
[root@std bin]# ./mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
在直接输入密码处直接回车登录数据库成功,省去了修改my.cnf文件的麻烦。
此中方式启动,关闭的时候也不需要密码,直接回车即可:
[root@std bin]# ./mysqladmin -u root -p shutdown
Enter password: --直接回车
8.配置mysql的启动环境,正常启动
[root@std mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/ [root@std mysql]# ln -s /usr/local/mysql/lib/* /usr/lib/ ln: creating symbolic link `/usr/lib/pkgconfig' to `/usr/local/mysql/lib/pkgconfig': File exists [root@std mysql]# ln -s /usr/local/mysql/include/* /usr/include/ [root@std mysql]# ldconfig [root@std mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@std mysql]# chmod 755 /etc/init.d/mysqld [root@std mysql]# chown mysql.mysql /etc/init.d/mysqld [root@std mysql]# /etc/init.d/mysqld start Starting MySQL.. [root@std init.d]# /etc/init.d/mysqld status MySQL running (13859)
此时就可以随便在任何目录执行mysql命令了,不用写全路径了:
[root@std ~]# mysql -V mysql Ver 14.14 Distrib 5.7.10, for linux-glibc2.5 (i686) using EditLine wrapper [root@std ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 4 Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> select version() ; +-----------+ | version() | +-----------+ | 5.7.10 | +-----------+ 1 row in set (0.00 sec) mysql>
参考:
http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
http://www.xker.com/page/e2015/07/211127.html
http://www.2cto.com/database/201508/433985.html