Deleting the wiki page 'docker容器(ubuntu 18.04)中使用源码安装mysql 5.7.36' cannot be undone. Continue?
1、下载mysql源码,https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.36.tar.gz
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.36.tar.gz
2、解压,两个分别解压到不同的目录。mysql-5.7.36.tar.gz解压到/mysql/mysql-5.7.36 目录,而mysql-boost-5.7.36.tar.gz解压到了/mysql/boost/mysql-5.7.36目录。
3、安装需要依赖的包:
apt-get install make cmake gcc g++ bison libncurses5-dev build-essential
apt-get install pkg-config
apt-get install libssl-dev
4、在/mysql/mysql-5.7.36目录下执行:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/tmp/mysql3306.sock -DMYSQL_TCP_PORT=3306 -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=ON -DSYSCONFDIR=/etc -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/mysql/boost/mysql-5.7.36
-DWITH_BOOST:指定解压后的mysql-boost目录
用cmake配置mysql预编译参数:
-DCMAKE_INSTALL_PREFIX:安装路径
-DMYSQL_DATADIR:数据存放目录
-DWITH_BOOST:boost源码路径
-DSYSCONFDIR:my.cnf配置文件目录
-DEFAULT_CHARSET:数据库默认字符编码
-DDEFAULT_COLLATION:默认排序规则
-DENABLED_LOCAL_INFILE:允许从本文件导入数据
-DEXTRA_CHARSETS:安装所有字符集
5、make -j 2
6、make install
7、配置数据库
(1)修改/etc/mysql/mysql.conf.d/mysqld.cnf
在 [mysqld]节点下
注释掉:#mysqlx-bind-address = 127.0.0.1
增加:
socket = /usr/local/mysql/mysql.sock
port = 3306
datadir = /usr/local/mysql/data
basedir = /usr/local/mysql
character-set-server = utf8
(2)修改/etc/mysql/mysql.conf.d/mysqld.cnf
增加:
[client]
port=3306
default-character-set = utf8
socket = /usr/local/mysql/mysql.sock
(3)初始化数据库
赋权限给目录:
chown -R mysql:mysql /usr/local/mysql
进入到/usr/local/mysql/bin目录,进行数据库初始化:
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --console
如果有输出root密码,则记录下,如果没有,则按照下面方法修改root密码。
(4)启动数据库:
在/usr/local/mysql/bin 目录下,运行:
./mysqld_safe &
回车之后,如果进程一直在,则启动成功,否则查看错误日志: /var/log/mysql/error.log , 需要解决。
(5)登录数据库
mysql -uroot -p
使用对应的root的密码登录,如果初始化数据库时,没有输出root密码,则如下处理:
先kill掉mysql两个进程,使用下面命令启动数据库
./mysqld_safe --skip-grant-tables &
然后进行
mysql -uroot -p
登录,直接回车,连接上之后,执行下面两条命令,修改密码。
SET PASSWORD = PASSWORD('pcl123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
完成之后,再kill掉mysql两个进程,然后正常启动:
./mysqld_safe &
之后,就可以使用 root和修改后的密码正常登录了。
(6)配置远程连接数据库
use mysql;
update user set authentication_string=password("pcl123456") where user="root";
grant all privileges on . to 'root'@'%' identified by 'pcl123456' with grant option;
update user set plugin="mysql_native_password";
flush privileges;
vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉 bind-address = 127.0.0.1
然后重新启动mysql数据库
Deleting the wiki page 'docker容器(ubuntu 18.04)中使用源码安装mysql 5.7.36' cannot be undone. Continue?
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》