Mysql是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(Relational Database Management System:关系数据库管理系统)应用软件之一。
下载地址:
https://dev.mysql.com/downloads/
需要下载社区版本,企业版是收费的使用30天.
查看是否有安装mysql
rpm -qa | grep -i mysql
-i :忽略大小写的不同
删除
yum -y remove mysql-libs*
解压下载的压缩包
tar -xvf mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
新增用户组
groupadd mysql
新增用户
useradd -r -g mysql mysql
-g:指定用户所属的起始群组。
-r:建立系统账号。
查看组和用户是否存在
cat /etc/group | grep mysql
cat /etc/passwd | grep mysql
chown命令改变某个文件或目录的所有者和所属的组
chown -R mysql mysql/
安装顺序
rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-test-5.7.21-1.el6.x86_64.rpm
如果出现错误:
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.21-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.21-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.21-1.el6.x86_64
运行
yum install -y numactl
yum install -y perl
yum install -y libaio
yum install -y perl-JSON.noarch
yum install -y perl-Time-HiRes
安装完成后查看版本
mysql --version 或 mysqladmin --version
数据库初始化并生成一个初始密码
mysqld --initialize-insecure --user=mysql
查看第一次登陆密码
cat /var/log/mysqld.log
启动数据库
service mysqld start
查看点口是否已经监听
netstat -tulnp | grep 3306
登录
mysql -u root -p
输入密码
o(kopljr(6hY
登录后修改密码
SET PASSWORD = PASSWORD('China123');
root在其他主机上也能链接到此数据库
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'China123' WITH GRANT OPTION;