下载源码git clone https://github.com/mysql/mysql-server.gitcd mysql-servergit checkout 5.7编译安装安装依赖yum install -y cmake make gcc gcc-c++ ncurses-devel bison gdb需要注意的一点,需要指定 boost 路径,会 cmake 的时候自动下载cd BUILD; cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory> -DWITH_DEBUG=1 -DWITH_UNIT_TESTS=offmake make install最后程序安装到了/usr/local/mysql目录创建专用用户groupadd mysqluseradd -s /sbin/nologin -M -g mysql mysql初始化数据库cd /usr/local/mysql/bin/mysqld –defaults-file=/etc/my.cnf –initialize –user=mysql2019-02-01T07:45:58.147032Z 1 [Note] A temporary password is generated for root@localhost: jss<swtX.8og连接数据库[root@bogon bin]# ./mysql -h localhost -urootERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)原来是因为配置文件里面没有置顶客户端的 socket 文件cat /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid## include all files from the config directory#!includedir /etc/my.cnf.d增加[client]default-character-set=utf8socket=/var/lib/mysql/mysql.sock[mysql]default-character-set=utf8socket=/var/lib/mysql/mysql.sock再次连接就 ok 了。修改默认密码SET PASSWORD = PASSWORD(‘123456’);ALTER USER ‘root’@’localhost’ PASSWORD EXPIRE NEVER;flush privileges;导入测试数据/usr/local/mysql/bin/mysql -uroot -p123456 test < article_rank.sqlhttps://www.linuxidc.com/Linu…https://www.cnblogs.com/debmz…