linux下mysql8安装

今天折腾了一下午,安装了mysql8.0.17.

官方查看安装步骤https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html。

根据我个人的安装情况,重新写一下安装过程,中间出现的问题,我在文章最后统一记录了下来。

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum update

//yum install mysql-server //由于网络原因下载比较慢,于是自己手动下载了包

//下载mysql-server mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

//解压

xz -d  mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

tar xvf  mysql-8.0.17-linux-glibc2.12-x86_64.tar

mv   mysql-8.0.17-linux-glibc2.12-x86_64 mysql

mv mysql /usr/local/

shell> groupadd mysql 

shell> useradd -r -g mysql -s /bin/false mysql 

shell> cd /usr/local

shell> cd mysql 

shell> mkdir mysql-files 

shell> chown mysql:mysql mysql-files 

shell> chmod 750 mysql-files 

shell> bin/mysqld --initialize --user=mysql  ##会创建一个root账户,有一个随机密码,记下来,如下图:

shell> bin/mysql_ssl_rsa_setup 

shell> bin/mysqld_safe --user=mysql &

# Next command is optional 

shell> cp support-files/mysql.server /etc/init.d/mysql.server

chown mysql:mysql -R /var/lib/mysql

#启动服务

support-files/mysql.server start

##连接

mysql -uroot -p

 

问题:

问题参考:https://blog.csdn.net/m0_37886429/article/details/78844358

缺包libnuma,error while loading shared libraries: libnuma.so.1

yum 安装的libnuma.so.1,但安装时默认安装的是32的,但db2需要的是64位的

1.如果已经安装了libnuma.so.1,先yum remove libnuma.so.1 

2.yum -y install numactl.x86_64

 

修改密码

问题参考:https://blog.csdn.net/Source_00/article/details/79902096

执行initialize后,会为root账户设置一个随机初始密码,记住密码,然后去重置密码,

我使用了上述链接方法中mysql_secure_installation 命令修改root密码

 

本地连接报错

mysql -uroot -p

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2),

问题参考:https://blog.csdn.net/u013631121/article/details/80875837

需要创建my.cnf并配置socket且 加入skip-grant-tables,我的/etc/my.cnf配置如下:

参考:https://blog.csdn.net/Source_00/article/details/79902096

[client]
 
port = 3306
 
 
socket = /var/run/mysqld/mysqld.sock   #该路径要与下面的路径一致,否则会报错
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # 一般配置选项
basedir = /usr/local/mysql   #mysql安装路径
datadir = /usr/local/mysql/data/mysqldata   #数据存储路径
port = 3306
socket = /var/run/mysqld/mysqld.sock   #该路径要与上面的路径一致,否则会报错
character-set-server=utf8
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M
skip-grant-tables
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6
server_id=1
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
default-character-set=utf8
safe-updates
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192

配置完成连接成功,就可以正常操作了!

 

 

你可能感兴趣的:(linux)