[root@localhost ~]#
如果发现如同上面执行的结果证明存在mysql数据库,将其卸载,并重新安装,卸载方法如下。
[root@localhost ~]# yum remove mysql mysql-*
然后就是漫长的卸载过程了,等卸载完成之后再次执行一下命令,看知否还有与MySQL相关的文件或模块,删除干净即可;
[root@localhost ~]# yum list installed | grep mysql
[root@localhost ~]# rpm -qa¦grep mysql
-qa¦grep: 未知的选项
[root@localhost local]# tar -zxf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz ##解压文件
[root@localhost mysql-5.6.30-linux-glibc2.5-x86_64]# useradd mysql ##创建用户
[root@localhost mysql-5.6.30-linux-glibc2.5-x86_64]# echo 'cdb123456'|passwd --stdin mysql ##设置用户密码
更改用户 mysql 的密码 。
passwd: 所有的身份验证令牌已经成功更新。
[root@localhost local]# chown -R mysql:mysql mysql-5.6.30-linux-glibc2.5-x86_64/ ##设置组,分配权限
[root@localhost ~]# su - mysql ##切换到数据库用户控制
[root@localhost ~]$ cd /usr/local/mysql-5.6.30-linux-glibc2.5-x86_64/scripts/ ##进入安装目录
[mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.6.30-linux-glibc2.5-x86_64 --datadir=/usr/local/mysql-5.6.30-linux-glibc2.5-x86_64/data ##执行安装命令,注意这行命令一定不要把路径写错了,否则会报错
安装成功之后会有以下的输出信息:
Installing MySQL system tables...2018-05-08 10:11:44 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-08 10:11:44 0 [Note] /usr/local/mysql-5.6.30-linux-glibc2.5-x86_64/bin/mysqld (mysqld 5.6.30) starting as process 8775 ...
2018-05-08 10:11:44 8775 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2018-05-08 10:11:44 8775 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2018-05-08 10:11:44 8775 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-08 10:11:44 8775 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-08 10:11:44 8775 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-08 10:11:44 8775 [Note] InnoDB: Memory barrier is not used
2018-05-08 10:11:44 8775 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-08 10:11:44 8775 [Note] InnoDB: Using Linux native AIO
2018-05-08 10:11:44 8775 [Note] InnoDB: Not using CPU crc32 instructions
2018-05-08 10:11:44 8775 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-05-08 10:11:44 8775 [Note] InnoDB: Completed initialization of buffer pool
2018-05-08 10:11:44 8775 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-05-08 10:11:44 8775 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-05-08 10:11:44 8775 [Note] InnoDB: Database physically writes the file full: wait...
2018-05-08 10:11:45 8775 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-05-08 10:11:46 8775 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-05-08 10:11:46 8775 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-05-08 10:11:46 8775 [Warning] InnoDB: New log files created, LSN=45781
2018-05-08 10:11:46 8775 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-05-08 10:11:46 8775 [Note] InnoDB: Doublewrite buffer created
2018-05-08 10:11:46 8775 [Note] InnoDB: 128 rollback segment(s) are active.
2018-05-08 10:11:46 8775 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-08 10:11:47 8775 [Note] InnoDB: Foreign key constraint system tables created
2018-05-08 10:11:47 8775 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-05-08 10:11:47 8775 [Note] InnoDB: Tablespace and datafile system tables created.
2018-05-08 10:11:47 8775 [Note] InnoDB: Waiting for purge to start
2018-05-08 10:11:47 8775 [Note] InnoDB: 5.6.30 started; log sequence number 0
2018-05-08 10:11:52 8775 [Note] Binlog end
2018-05-08 10:11:52 8775 [Note] InnoDB: FTS optimize thread exiting.
2018-05-08 10:11:52 8775 [Note] InnoDB: Starting shutdown...
2018-05-08 10:11:54 8775 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2018-05-08 10:11:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-08 10:11:54 0 [Note] /usr/local/mysql-5.6.30-linux-glibc2.5-x86_64/bin/mysqld (mysqld 5.6.30) starting as process 8798 ...
2018-05-08 10:11:54 8798 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2018-05-08 10:11:54 8798 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2018-05-08 10:11:54 8798 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-08 10:11:54 8798 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-08 10:11:54 8798 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-08 10:11:54 8798 [Note] InnoDB: Memory barrier is not used
2018-05-08 10:11:54 8798 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-08 10:11:54 8798 [Note] InnoDB: Using Linux native AIO
2018-05-08 10:11:54 8798 [Note] InnoDB: Not using CPU crc32 instructions
2018-05-08 10:11:54 8798 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-05-08 10:11:54 8798 [Note] InnoDB: Completed initialization of buffer pool
2018-05-08 10:11:54 8798 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-08 10:11:54 8798 [Note] InnoDB: 128 rollback segment(s) are active.
2018-05-08 10:11:54 8798 [Note] InnoDB: Waiting for purge to start
2018-05-08 10:11:54 8798 [Note] InnoDB: 5.6.30 started; log sequence number 1625977
2018-05-08 10:11:54 8798 [Note] Binlog end
2018-05-08 10:11:54 8798 [Note] InnoDB: FTS optimize thread exiting.
2018-05-08 10:11:54 8798 [Note] InnoDB: Starting shutdown...
2018-05-08 10:11:56 8798 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
strongly recommended for production servers.
See the manual for more instructions.[mysql@localhost scripts]$
上面蓝色字体部分大致意思是告诉我们,安装成功之后,要重新设置密码,并且要用黄色字体部分的命令行来实现。
依次执行下面的命令打开配置文件
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost ~]# vim /etc/init.d/mysql
修改配置文件,如图所示:
启动服务:
[root@localhost mysql-5.6.30-linux-glibc2.5-x86_64]# chkconfig --add mysql
[root@localhost mysql-5.6.30-linux-glibc2.5-x86_64]# chkconfig mysql on
[root@localhost mysql-5.6.30-linux-glibc2.5-x86_64]# service mysql start
Starting MySQL.. SUCCESS!
设置新密码:
[root@localhost ~]# /usr/local/mysql-5.6.30-linux-glibc2.5-x86_64/bin/mysqladmin -u root password '你的新密码'
登陆mysql:
配置登陆权限:
好了,现在你可以丧心病狂的蹂躏你的系统了;