mysql5.7.20 centos7 解压版安装

来源:互联网 发布:maya软件破解版 编辑:程序博客网 时间:2024/06/05 21:53

1.下载安装包

    https://dev.mysql.com/downloads/file/?id=473563


2.解压文件,复制到/usr/local

    tar -xvf mysql-5.7.20-linux-glibc2.12-x86_64.tar     解压后有有两个文件:mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz,mysql-test-5.7.20-linux-glibc2.12-x86_64.tar.gz

   tar -xzvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz 解压后文件名为:mysql-5.7.20-linux-glibc2.12-x86_64,

   mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql  重命名

   cp mysql /usr/local/ -r  复制

   cd /usr/local 进入安装文件夹

3. 增加用户

[root@localhost mysql]# groupadd mysql
[root@localhost mysql]# useradd -r -g mysql mysql
[root@localhost mysql]# cd ..
[root@localhost local]# chown -R mysql mysql/
[root@localhost local]#  chgrp -R mysql mysql/
[root@localhost local]# cd mysql/
[root@localhost mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2017-12-18 15:38:29 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-12-18 15:38:31 [WARNING] The bootstrap log isn't empty:
2017-12-18 15:38:31 [WARNING] 2017-12-18T07:38:29.824248Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-12-18T07:38:29.835981Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-12-18T07:38:29.836022Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)


4.安装

[root@localhost mysql]# cp -a ./support-files/mysql.server  /etc/init.d/mysqld

[root@localhost mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf
cp: 无法获取"./support-files/my-default.cnf" 的文件状态(stat): 没有那个文件或目录 

当报这个错误的时候增加一个my-default.cnf 文件。内容配置如下:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.


[mysqld]


# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M


# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin


# These are commonly set, remove the # and set as required.
 basedir = /usr/local/mysql
 datadir = /usr/local/mysql/data
# port = .....
# server_id = .....
# socket = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


然后在执行:

[root@localhost mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@localhost mysql]# ll

[root@localhost mysql]# cd bin
[root@localhost bin]# ./mysqld_safe --user=mysql &
[1] 8475
[root@localhost bin]# Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2017-12-18T07:47:16.901751Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data


[root@localhost bin]#
[root@localhost bin]#
[root@localhost bin]# /etc/init.d/mysqld restart
Shutting down MySQL..2017-12-18T07:47:43.297782Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended
 SUCCESS!
Starting MySQL. SUCCESS!
[1]+  完成                  ./mysqld_safe --user=mysql


5.初始化密码,以及添加远程访问

[root@localhost bin]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2017-12-18 15:38:29
(Af_i4,i(.E;
[root@localhost bin]# ./mysql -uroot -p
Enter password:

mysql> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('yangdi');
Query OK, 0 rows affected, 1 warning (0.00 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.20    |
+-----------+
1 row in set (0.00 sec)


mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> select host, user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys     |
| localhost | root          |
+-----------+---------------+
3 rows in set (0.00 sec)


mysql>  update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0


mysql>quit;

[root@localhost bin]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@localhost bin]# ps -ef |grep mysql


设置开机启动

[root@localhost bin]#chkconfig --level35 mysqld on


6.使用navicate 连接,检查防火墙状态!!!!






原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 狗狗对主人低吼怎么办 吹雪之松锦徒长怎么办 武装突袭被禁了怎么办 眼球小血管破了怎么办 眼睛白眼球破了怎么办 打拳击手腕伤了怎么办 上眼皮进东西了怎么办 眼睛进了异物怎么办妙招 眼睛毛血管破了怎么办 怪物猎人x钱不够怎么办 小米2开不了机怎么办 3ds更新系统不动怎么办 u盘中病毒了怎么办 aj5白银前面皱了怎么办 狗吃了巧克力该怎么办 孩子零食吃多了怎么办 上学时月经侧漏怎么办 漏电被电的脚肿怎么办 走路有尿溢出来怎么办 篮球气嘴漏气了怎么办 暗线插座盒坏了怎么办 焊过电焊眼睛疼怎么办 烧电焊后眼睛痛怎么办? 焊完电焊眼睛疼怎么办 烧电焊后眼睛痛怎么办 用电焊后眼睛痛怎么办 看电焊后眼睛痛怎么办 眼睛焊电焊很痛怎么办 电焊没带眼睛痛怎么办 有东西进眼睛了怎么办 眼睛有东西磨眼怎么办 怀孕了眼睛肿疼怎么办 眼睛疼又红血丝怎么办 用眼过度眼睛疼怎么办 眼睛玩手机视力下降怎么办 看手机眼睛疼该怎么办 眼睛眨一下就痛怎么办 着火了怎么办教案详案 汽车尾灯磕破了怎么办 后尾灯灯罩裂了怎么办 七氟丙烷喷伤了怎么办