2018年10月1日
CentOS 7安装mysql 8.0.12数据库
步骤一:安装mysql依赖
yum install -y libaio numactl wget
步骤二:下载mysql社区版
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
步骤三:创建mysql用户和用户组
groupadd mysql useradd -r -g mysql -s /bin/false mysql
步骤四:解压mysql文件
tar xvf mysql-* -C /usr/local ln -s /usr/local/mysql-* /usr/local/mysql cd /usr/local/mysql
步骤五:创建文件夹
mkdir mysql-files chown mysql:mysql mysql-files chmod 750 mysql-files mkdir /var/log/mysql touch /var/log/mysql/mysql.log chown -R mysql:mysql /var/log/mysql chmod -R 750 /var/log/mysql
步骤六:初始化mysql
将root初始化密码复制出来,等会登录mysql需要使用这个密码
bin/mysqld --initialize --user=mysql bin/mysql_ssl_rsa_setup bin/mysqld_safe --user=mysql cp support-files/mysql.server /etc/init.d/mysqld
步骤七:分配mysql文件夹权限
chown -R mysql:mysql /usr/local/mysql* chmod -R 751 /usr/local/mysql*
步骤八:启动mysql
service mysqld start
步骤九:配置环境变量
vi /etc/profile 写入"export PATH=$PATH:/usr/local/mysql/bin" source /etc/profile
步骤十:更改mysql密码
mysql -uroot -p #密码是刚刚执行(bin/mysqld --initialize --user=mysql)命令复制出来的密码 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'New_Password'; flush privileges;
可选项:开机自启动mysql数据库
systemctl enable mysqld
可选项:新建mysql用户并授权
CREATE USER 新建用户名 IDENTIFIED BY 密码; GRANT SELECT, INSERT, UPDATE, DELETE ON 数据库名称 TO 新建用户名; flush privileges;
问题处理:
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such fileor directory [root@DNF data]# find / -name "*libtinfo*" /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.6.1 [root@DNF data]# cp /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
参考文献:
https://zhuanlan.zhihu.com/p/38708106 https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html