centos7安装数据库 (系统包含预装环境mariadb)
作者:互联网
查看系统是否安装了MySQL,有些没安装但是有路径,那是因为系统安装了mariadb-libs,对应的配置文件目录:/etc/my.cnf(下面就根据mariadb来安装mysql)
查看系统预装mariadb:rpm -qa | grep mariadb
1、将解压过的MySQL放到/usr/local目录下,并重命名为mysql
2、安装依赖包libaio:检查,rpm -q libaio,若没安装则需进行安装:yum -y install libaio
3、建立MySQL用户和用户组:useradd -s /sbin/nologin -M mysql
4、初始化数据库:./mysqld --initialize --user=mysql
当初始化时报错(bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory)此时安装numactl后再去初始化:yum -y install numactl
5、复制启动、关闭脚本:cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
6、修改配置文件:etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
[client]
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
7、启动数据库:service mysqld start
8、测试数据库:进入MySQL的bin,输入 ./mysql -u root -p;提示输入密码,密码就是初始化数据库时的那个
9、更改数据库密码:alter user 'root'@'localhost' identified by '新密码';
标签:数据库,预装,centos7,mysqld,mysql,MySQL,mariadb,安装 来源: https://www.cnblogs.com/chenliming/p/11876244.html