MySQL8数据库安装部署
- 准备
卸载之前安装过的版本
确保之前安装过的版本完全卸载,包括老版本使用的数据文件。检查“/etc/my.cnf”,“/etc/mysql”,删除。
依赖库 - libaio
影响到数据目录初始化、服务启动。 - 安装
启动MySQL的最简单方法:groupadd mysql useradd -r -g mysql -s /bin/false mysql # jeecg项目需要忽略掉数据库大小写 bin/mysqld --initialize --user=mysql --lower-case-table-names=1 bin/mysqld_safe --user=mysql & # Next command is optional cp support-files/mysql.server /etc/init.d/mysql.server # reset password mysql -uroot -p alter user root@localhost identified by '';
为启动脚本添加配置选项/etc/my.cnf:
[mysqld] datadir=/usr/local/mysql/var socket=/var/tmp/mysql.sock port=3306 user=mysql [mysql.server] basedir=/usr/local/mysql
- 创建对象
创建数据库、创建用户并授权
create database if not exists db_name character set = utf8; create user user_name@'host_name' identified by 'user_pass'; grant all privileges on db_name.* to 'user_name'@host_name; show grants for 'user_name'@host_name;
解决mysql2058
alter user 'user_name'@'host_name' identified with mysql_native_password by 'user_pass';
- 多实例运行
选项:# Must have different values for each server instance. port=port_num socket={file_name|pipe_name} bind_address=0.0.0.0 datadir=dir_name pid-file=file_name # log file options general_log_file=file_name log-bin[=file_name] slow_query_log_file=file_name log-error[=file_name] # To achieve better performance. tmpdir=dir_name
MySQL5