我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

MySQL5.7安装-创新互联

1、下载安装包

成都创新互联专注于企业营销型网站、网站重做改版、灵石网站定制设计、自适应品牌网站建设、H5建站商城开发、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为灵石等各大城市提供网站开发制作服务。
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

2、解压到/opt下

[root@Master opt]# tar xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
[root@Master opt]# ll
total 628712
drwxr-xr-x. 9 root root      4096 Jul  6 19:47 mysql-5.7.22-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root 643790848 Jul  6 11:44 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

3、作软链接到/usr/local/mysql

[root@Master opt]# ln -s /opt/mysql-5.7.22-linux-glibc2.12-x86_64  /usr/local/mysql
[root@Master opt]# ll /usr/local/
total 40
drwxr-xr-x. 2 root root 4096 Sep 23  2011 bin
drwxr-xr-x. 2 root root 4096 Sep 23  2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23  2011 games
drwxr-xr-x. 2 root root 4096 Sep 23  2011 include
drwxr-xr-x. 2 root root 4096 Sep 23  2011 lib
drwxr-xr-x. 2 root root 4096 Sep 23  2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23  2011 libexec
lrwxrwxrwx. 1 root root   40 Jul  6 20:01 mysql -> /opt/mysql-5.7.22-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 4096 Sep 23  2011 sbin
drwxr-xr-x. 5 root root 4096 Feb 16  2017 share
drwxr-xr-x. 2 root root 4096 Sep 23  2011 src

4、创建用户

[root@Master opt]# groupadd mysql 
[root@Master opt]#  useradd -g mysql  -s  /sbin/nologin -d /usr/local/mysql/  -M mysql

5、环境变量

[root@Master opt]# echo PATH=$PATH:/usr/local/mysql/bin >>/etc/profile 
[root@Master opt]# source /etc/profile

6、创建必须的目录

mkdir -p /data/mysql/mysql3306/{data,tmp,logs}

7、生成my.cnf(根据自己需求自动生成)
叶总的配置文件生成工具
http://imysql.com/my-cnf-wizard.html
8、目录权限

[root@Master /]# chown -R mysql:mysql /data/mysql/mysql3306/
[root@Master /]# chown -R mysql:mysql /usr/local/mysql

9、数据库初始化

[root@Master /]# mysqld --defaults-file=/etc/my.cnf --initialize --user=user --basedir=/usr/local/mysql/  --datadir=/data/mysql/mysql3306/data/

10、数据库密码(.lZ!-2t2-n9s)

[root@Master data]# more /data/mysql/mysql3306/data/dataerror.log
2018-07-06T13:46:32.795821Z 1 [Note] A temporary password is generated for root@localhost: .lZ!-2t2-n9s

11、启动数据库

[root@Master support-files]# pwd
/usr/local/mysql/support-files
[root@Master support-files]# cp mysql.server   /etc/init.d/mysqld
[root@Master support-files]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!

12、登录数据库

输入第10步的密码
Starting MySQL.. SUCCESS! 
[root@Master support-files]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22-log

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@Master 21:57:  [(none)]> 
root@Master 21:57:  [(none)]> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement

13、改root密码

[root@Master support-files]# mysqladmin -uroot -p password 'root'
Enter password: 
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety

14、登录数据库

[root@Master support-files]# mysql -uroot -proot                 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.22-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@Master 22:01:  [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

问题:

初始化时遇到报错
error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

解决:

yum -y install numactl.x86_64

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:MySQL5.7安装-创新互联
文章位置:http://mswzjz.cn/article/dosisj.html

其他资讯