mysql(二进制安装篇)

发表于 2019-09-19  272 次阅读


安装依赖

yum -y install gcc cmake make gcc-c++ ncurses-devel openssl-devel bison ncurses chkconfig lsof libaio*
下载安装包
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.26-el7-x86_64.tar.gz
解压
  tar zxvf mysql-5.7.26-el7-x86_64.tar.gz
  mv mysql-5.7.26-el7-x86_64 mysql
添加mysql用户和用户组
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
给mysql用户授权mysql 文件夹
1
chown -R mysql:mysql /usr/local/mysql/
拷贝启动文件
1
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
初始化数据库
1
2
#使用-initialize会生成随机密码,使用-initialize-insecure生成空密码,这里选择生成空密码。
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql
启动MySql
1
2
3
4
#启动MySql
/etc/init.d/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/VM_0_15_centos.err'.
SUCCESS!
添加至环境变量
1
2
3
4
5
6
#使其永久生效,把安装目录添加至环境变量
vim /etc/profile
#文件最后一行添加进去
export PATH=$PATH:/usr/local/mysql/bin
#马上生效
source /etc/profile
登陆mysql
1
mysql -uroot -p
修改密码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#查看数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
#修改root密码为123456
mysql> set password for root@localhost = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
#退出mysql,重新登陆生效
mysql> exit
Bye

本站文章基于国际协议BY-NA-SA 4.0协议共享;
如未特殊说明,本站文章皆为原创文章,请规范转载。

0