安装工具cmake
root@Toka:~#
root@Toka:~# wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
root@Toka:~# tar -zxvf cmake-3.7.0.tar.gz
root@Toka:~# cd cmake-3.7.0
root@Toka:~# ./bootstrap
root@Toka:~# make
root@Toka:~# make install
root@Toka:~# #或者直接在线安装cmake
root@Toka:~# apt-get install cmake
下载mysql:mysql-5.7.4-m14.tar.gz、mysql-8.0.0-dmr.tar.gz、mysql-5.7.15.tar.gz
root@Toka:~# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.15.tar.gz
root@Toka:~# tar -zxvf mysql-5.7.15.tar.gz
root@Toka:~# cd mysql-5.7.15
root@Toka:~# 下面这条命令中的“.”表示当前目录,不能漏了!!!
root@Toka:~# cmake .
CMake Error at cmake/readline.cmake:64 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:107 (FIND_CURSES)
cmake/readline.cmake:181 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:467 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
root@Toka:~# 上面报错主要提示缺少libncurses5-dev,所以下面安装缺少的libncurses5-dev
root@Toka:~# apt-get install libncurses5-dev
root@Toka:~# 重新cmake
root@Toka:~# cmake .
Configuring done
Generating done
root@Toka:~# 成功了,继续下面的安装
root@Toka:~# make
root@Toka:~# make install
至此安装完成,但还要做一定的配置就可以使用mysql了
root@Toka:~# 创建mysql专属的用户名和组名
root@Toka:~# groupadd mysql
root@Toka:~# useradd -r -g mysql mysql
root@Toka:~# cd /usr/local/mysql
root@Toka:~# chown -R mysql .
root@Toka:~# chgrp -R mysql .
root@Toka:~# scripts/mysql_install_db --user=mysql
root@Toka:~# chown -R root .
root@Toka:~# chown -R mysql data
以下为mysql 5.7版本才需要
root@Toka:~# vim my.cnf
#加入如下行,这样就可以不用密码登录了
skip-grant-tables
#保存退出
root@Toka:~# 启动mysql
root@Toka:~# support-files/mysql.server start
root@Toka:~# bin/mysql -h localhost -u root
mysql> use mysql;
mysql> update user set password=password('123456') where user='root';
mysql> flush privileges;
mysql> exit;
root@Toka:~# vim my.cnf
#再注销刚才这一行
#skip-grant-tables
#保存退出
root@Toka:~# support-files/mysql.server restart
root@Toka:~# bin/mysql -h localhost -u root -p123456
mysql> SET PASSWORD=PASSWORD('新的密码');
mysql> exit;
root@Toka:~# 至此mysql密码修改完成
重新启动mysql:
/usr/local/mysql/support-files/mysql.server restart
root@Toka:~# 覆盖系统默认的mysql 低版本的服务,可以讲如下脚本拷入系统启动目录。
root@Toka:~# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
root@Toka:~# 到此安装完成
大功告成!!!!
非本机用户还不能登录而出现ERROR 1130的话,要改mysql数据库里的user表
如下
root@Toka:~# mysql -h localhost -u root
Mysql> use mysql;
Mysql> update mysql.user set host='%' where user='root' and host='localhost';
Mysql> UPDATE `mysql`.`user` SET `password` = PASSWORD( 'kaQWkd,.23Ks' ) WHERE `user`.`Host` = CAST( 0x25 AS BINARY ) AND `user`.`User` = CAST( 0x726f6f74 AS BINARY ) ;
Mysql> exit;
root@Toka:~# /usr/local/mysql/support-files/mysql.server restart