Ubuntu 安装 Mysql8

下载地址:https://dev.mysql.com/downloads/mysql/

Select Operating System:Linux-Generic

Select OS Version:Linux - Generic (glibc 2.17) (x86, 64-bit)

Select Package:Compressed TAR Archive, Minimal Install

上传目录:/usr/local/src

安装目录:/usr/local/mysql

 

## 参考资料

官网:https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html

 

## 源码安装


# 添加用户组和用户
groupadd mysql
useradd -r -g mysql -s /bin/false mysql

# 进入安装包目录,解压,拷贝
cd /usr/local/src
tar -xvf mysql-8.0.xxx
mv mysql-8.0.xxx /usr/local/mysql cd /usr/local/mysql/ # 创建配置文件
vim my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
character-set-server=utf8mb4

[mysqld_safe]
log-error=/usr/local/mysql/error.log
pid-file=/usr/local/mysql/mysqld.pid

[mysql]
default-character-set=utf8mb4

[client]
default-character-set=utf8mb4

 

mkdir data
touch error.log
chown -R mysql:mysql /usr/local/mysql

# 安装 bin
/mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --user=mysql #记录随机密码root@localhost: xxx bin/mysql_ssl_rsa_setup bin/mysqld_safe --user=mysql &

# 启动
support-files/mysql.server start
# 重启
support-files/mysql.server restart
# 关闭
support-files/mysql.server stop

# 修改密码
bin/mysql -uroot -p【上面记录的密码】
alter user root@localhost identified by 'root';

 

### 第一次启动会失败,原因未知

The server quit without updating PID file (/usr/local/mysql/data/VM_0_13_[FAILED]id).

# 杀掉mysql进程,重新启动
ps aux|grep mysql
kill 进程ID
support-files/mysql.server start

 

error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

apt install -y libncurses5

 

posted @ 2018-08-25 14:26  绿静風  阅读(1602)  评论(0编辑  收藏  举报