centos中安装mysql详细步骤说明
1、安装依赖
[root@node001 ~]# yum install -y perl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Setting up Install Process
Package 4:perl-5.10.1-144.el6.x86_64 already installed and latest version
Nothing to do
2、 卸载旧版本的mysql及插件
[root@node001 ~]# rpm -qa | grep mysql
mysql-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
[root@node001 ~]# rpm -e mysql-5.1.73-8.el6_8.x86_64 --nodeps
[root@node001 ~]# rpm -e mysql-libs-5.1.73-8.el6_8.x86_64 --nodeps
[root@node001 ~]# rpm -e mysql-server-5.1.73-8.el6_8.x86_64 --nodeps
(--nodeps:忽略其他依赖,直接卸载)
3、 安装rpm(4个)
安装包
[root@node001 ~]# tar zxvf mysql.tar.gz
MySQL-client-5.6.28-1.el6.x86_64.rpm
MySQL-devel-5.6.28-1.el6.x86_64.rpm
MySQL-server-5.6.28-1.el6.x86_64.rpm
numactl-2.0.9-2.el6.x86_64.rpm
[root@node001 ~]# rpm -ivh MySQL-client-5.6.28-1.el6.x86_64.rpm
warning: MySQL-client-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@node001 ~]# rpm -ivh MySQL-devel-5.6.28-1.el6.x86_64.rpm
warning: MySQL-devel-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
[root@node001 ~]# rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:numactl ########################################### [100%]
[root@node001 ~]# rpm -ivh MySQL-server-5.6.28-1.el6.x86_64.rpm
warning: MySQL-server-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
2017-12-24 05:39:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestam
p server option (see documentation for more details).2017-12-24 05:39:08 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1287 ...
2017-12-24 05:39:08 1287 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:39:08 1287 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:39:08 1287 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:39:08 1287 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:39:08 1287 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:39:08 1287 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:39:08 1287 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:39:08 1287 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-24 05:39:08 1287 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:39:08 1287 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-12-24 05:39:08 1287 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-12-24 05:39:08 1287 [Note] InnoDB: Database physically writes the file full: wait...
2017-12-24 05:39:09 1287 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-12-24 05:39:10 1287 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-12-24 05:39:11 1287 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-12-24 05:39:11 1287 [Warning] InnoDB: New log files created, LSN=45781
2017-12-24 05:39:11 1287 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-12-24 05:39:11 1287 [Note] InnoDB: Doublewrite buffer created
2017-12-24 05:39:11 1287 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:39:11 1287 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-24 05:39:11 1287 [Note] InnoDB: Foreign key constraint system tables created
2017-12-24 05:39:11 1287 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-12-24 05:39:11 1287 [Note] InnoDB: Tablespace and datafile system tables created.
2017-12-24 05:39:11 1287 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:39:11 1287 [Note] InnoDB: 5.6.28 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2017-12-24 05:39:11 1287 [Note] Binlog end
2017-12-24 05:39:11 1287 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:39:11 1287 [Note] InnoDB: Starting shutdown...
2017-12-24 05:39:13 1287 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2017-12-24 05:39:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestam
p server option (see documentation for more details).2017-12-24 05:39:13 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1309 ...
2017-12-24 05:39:13 1309 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:39:13 1309 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:39:13 1309 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:39:13 1309 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:39:13 1309 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:39:13 1309 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:39:13 1309 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:39:13 1309 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-24 05:39:13 1309 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:39:13 1309 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-24 05:39:13 1309 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:39:13 1309 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:39:13 1309 [Note] InnoDB: 5.6.28 started; log sequence number 1625977
2017-12-24 05:39:13 1309 [Note] Binlog end
2017-12-24 05:39:13 1309 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:39:13 1309 [Note] InnoDB: Starting shutdown...
2017-12-24 05:39:15 1309 [Note] InnoDB: Shutdown completed; log sequence number 1625987
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
4、上传mysql配置文件my.cnf
[root@node001 ~]# cd /etc
上传文件
[root@node001 etc]# ls /etc/my.cnf
/etc/my.cnf
5、初始化
[root@node001 etc]# /usr/bin/mysql_install_db
Installing MySQL system tables...2017-12-24 05:41:57 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-log) starting as process 1353 ...
2017-12-24 05:41:57 1353 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:41:57 1353 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:41:57 1353 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:41:57 1353 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:41:57 1353 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:41:57 1353 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:41:57 1353 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:41:57 1353 [Note] InnoDB: Initializing buffer pool, size = 64.0M
2017-12-24 05:41:57 1353 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:41:57 1353 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-24 05:41:57 1353 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*2048 pages, LSN=1625987
2017-12-24 05:41:57 1353 [Warning] InnoDB: Starting to delete and rewrite log files.
2017-12-24 05:41:57 1353 [Note] InnoDB: Setting log file ./ib_logfile101 size to 32 MB
2017-12-24 05:41:58 1353 [Note] InnoDB: Setting log file ./ib_logfile1 size to 32 MB
2017-12-24 05:41:58 1353 [Note] InnoDB: Setting log file ./ib_logfile2 size to 32 MB
2017-12-24 05:41:58 1353 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-12-24 05:41:58 1353 [Warning] InnoDB: New log files created, LSN=1625987
2017-12-24 05:41:58 1353 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:41:58 1353 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:41:58 1353 [Note] InnoDB: 5.6.28 started; log sequence number 1625987
2017-12-24 05:41:59 1353 [Note] Binlog end
2017-12-24 05:41:59 1353 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:41:59 1353 [Note] InnoDB: Starting shutdown...
2017-12-24 05:42:00 1353 [Note] InnoDB: Shutdown completed; log sequence number 1626134
OK
Filling help tables...2017-12-24 05:42:00 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-log) starting as process 1376 ...
2017-12-24 05:42:00 1376 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:42:00 1376 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:42:00 1376 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:42:00 1376 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:42:00 1376 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:42:00 1376 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:42:00 1376 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:42:00 1376 [Note] InnoDB: Initializing buffer pool, size = 64.0M
2017-12-24 05:42:00 1376 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:42:00 1376 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-24 05:42:00 1376 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:42:00 1376 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:42:00 1376 [Note] InnoDB: 5.6.28 started; log sequence number 1626134
2017-12-24 05:42:01 1376 [Note] Binlog end
2017-12-24 05:42:01 1376 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:42:01 1376 [Note] InnoDB: Starting shutdown...
2017-12-24 05:42:02 1376 [Note] InnoDB: Shutdown completed; log sequence number 1626144
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h 192.168.178.161 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
6、 启动mysql
[root@node001 etc]# service mysql start
Starting MySQL....... SUCCESS!
7、重置密码
查看初始化密码
[root@node001 etc]# cat /root/.mysql_secret
# The random password set for the root user at Sun Dec 24 05:39:11 2017 (local time): DMBe85LznCxRo16N
[root@node001 etc]# mysql -u root -pDMBe85LznCxRo16N
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 2
Server version: 5.6.28-log
Copyright (c) 2000, 2015, 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.
mysql> set password=password('mysql');
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
8、远程授权
原因:默认远程无法连接
授权命令:
mysql> grant all privileges on *.* to 'root'@'%' identified by 'mysql' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Linux查找筛选grep命令
Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。grep全称是Global Regular Expression Print,表示全局正则表达式版本,它的使用权限是所有用户。 grep可用于shell脚本,因为grep通过返回一个状态值来说明搜索的状态,如果模板搜索成功,则返回0,如果搜索不成功,则返回1,如果搜索的文件不存在,则返回2。我们利用这些返回值就可进行一些自动化的文本处理工作。 egrep是grep的一个超集,优化了很多操作。 命令格式:grep [option] pattern file -a –text #不要忽略二进制的数据。 -v –revert-match #显示不包含匹配文本的所有行。 -c –count #计算每个文件中符合样式的列数。 -n –line-number #在显示符合样式的那一行之前,标示出该行的列数编号。 -i –ignore-case #忽略字符大小写的差别。 -q –quiet或–silent #不显示任何信息 -s –no-messages #不显示错误信息。 -l –...
- 下一篇
centos 磁盘分区、格式化及挂载
当新增硬盘时,要做的几个事情就是:先按需要进行分区、然后对分区进行格式化、再进行挂载即将指定分区挂到指定目录上;必要的时候做下校验; 常用的命令有: fdisk :磁盘分区相关指令 如:查看 新增 删除 合并 分区等 partproabe:重读分区表 mkfs:将分区格式化成指定文件系统格式 mount :将指定分区挂载到指定目录 umount:卸载指定分区 第1步 添加新的磁盘分区 先通过fdisk -l 查看所有磁盘分区情况 或者df -aT 查看分区的使用情况; 分区是否被挂载 等等.. df命令 查看文件系统的整体磁盘使用情况 如:分区名称、使用量、可用量、挂载点(目录);默认显示单位为KB。 -a或--all:包含全部的文件系统; --block-size=<区块大小>:以指定的区块大小来显示区块数目; -h或--human-readable:以可读性较高的方式来显示信息; -H或--si:与-h参数相同,但在计算时是以1000 Bytes为换算单位而非1024 Bytes; -i或--inodes:显示inode的信息; -k或--kilobyte...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- CentOS6,7,8上安装Nginx,支持https2.0的开启
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- Windows10,CentOS7,CentOS8安装Nodejs环境
- 设置Eclipse缩进为4个空格,增强代码规范
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS8编译安装MySQL8.0.19
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7