Centos 下彻底重装 Mysql

环境介绍:

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-358.el6.i686 #1 SMP Thu Feb 21 21:50:49 UTC 2013 i686 i686 i386 GNU/Linux

[root@localhost ~]# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
 


第一步:在 http://www.mysql.com/下载想要的Mysql版本,我的对应如下

[clebeg@localhost download]$ ls
MySQL-5.6.16-1.linux_glibc2.5.i386.rpm-bundle.tar //该包已经集成sever、client等等

[clebeg@localhost mysql]$ ls
MySQL-client-5.6.16-1.linux_glibc2.5.i386.rpm
MySQL-devel-5.6.16-1.linux_glibc2.5.i386.rpm
MySQL-embedded-5.6.16-1.linux_glibc2.5.i386.rpm
MySQL-server-5.6.16-1.linux_glibc2.5.i386.rpm
MySQL-shared-5.6.16-1.linux_glibc2.5.i386.rpm
MySQL-shared-compat-5.6.16-1.linux_glibc2.5.i386.rpm
MySQL-test-5.6.16-1.linux_glibc2.5.i386.rpm
 


第二步:查看自己电脑是否已经安装有mysql

[clebeg@localhost mysql]$ sudo netstat -tap | grep mysql
tcp        0      0 202.38.221.21:49449         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49452         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49456         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49453         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49455         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49458         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49459         mysql-adc.oracle.com:http   TIME_WAIT   -                   
tcp        0      0 202.38.221.21:49450         mysql-adc.oracle.com:http   TIME_WAIT   -  

[clebeg@localhost mysql]$ sudo find / -name mysql
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/lib/mysql
/var/lib/mysql
/var/lib/mysql/mysql
                 


第三步:删除Mysql

[clebeg@localhost mysql]$sudo yum remove  mysql mysql-server mysql-libs mysql-server

把上面find命令找到的所有目录rm掉

[clebeg@localhost mysql]$ sudo rpm -qa | grep mysql //找到的包通通 yum remove




第四步:安装Mysql

[clebeg@localhost mysql]$ sudo rpm -ivh MySQL-server-5.6.16-1.linux_glibc2.5.i386.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2014-03-10 16:15:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-03-10 16:15:47 7248 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2014-03-10 16:15:47 7248 [Note] InnoDB: The InnoDB memory heap is disabled
2014-03-10 16:15:47 7248 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2014-03-10 16:15:47 7248 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-03-10 16:15:47 7248 [Note] InnoDB: Using Linux native AIO
2014-03-10 16:15:47 7248 [Note] InnoDB: Not using CPU crc32 instructions
2014-03-10 16:15:47 7248 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-03-10 16:15:47 7248 [Note] InnoDB: Completed initialization of buffer pool
2014-03-10 16:15:47 7248 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-03-10 16:15:47 7248 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-03-10 16:15:47 7248 [Note] InnoDB: Database physically writes the file full: wait...
2014-03-10 16:15:47 7248 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-03-10 16:15:48 7248 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-03-10 16:15:49 7248 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-03-10 16:15:49 7248 [Warning] InnoDB: New log files created, LSN=45781
2014-03-10 16:15:49 7248 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-03-10 16:15:49 7248 [Note] InnoDB: Doublewrite buffer created
2014-03-10 16:15:49 7248 [Note] InnoDB: 128 rollback segment(s) are active.
2014-03-10 16:15:49 7248 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-03-10 16:15:49 7248 [Note] InnoDB: Foreign key constraint system tables created
2014-03-10 16:15:49 7248 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-03-10 16:15:49 7248 [Note] InnoDB: Tablespace and datafile system tables created.
2014-03-10 16:15:49 7248 [Note] InnoDB: Waiting for purge to start
2014-03-10 16:15:50 7248 [Note] InnoDB: 5.6.16 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2014-03-10 16:15:55 7248 [Note] Binlog end
2014-03-10 16:15:55 7248 [Note] InnoDB: FTS optimize thread exiting.
2014-03-10 16:15:55 7248 [Note] InnoDB: Starting shutdown...
2014-03-10 16:15:57 7248 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2014-03-10 16:15:57 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-03-10 16:15:57 7277 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2014-03-10 16:15:57 7277 [Note] InnoDB: The InnoDB memory heap is disabled
2014-03-10 16:15:57 7277 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2014-03-10 16:15:57 7277 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-03-10 16:15:57 7277 [Note] InnoDB: Using Linux native AIO
2014-03-10 16:15:57 7277 [Note] InnoDB: Not using CPU crc32 instructions
2014-03-10 16:15:57 7277 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-03-10 16:15:57 7277 [Note] InnoDB: Completed initialization of buffer pool
2014-03-10 16:15:57 7277 [Note] InnoDB: Highest supported file format is Barracuda.
2014-03-10 16:15:57 7277 [Note] InnoDB: 128 rollback segment(s) are active.
2014-03-10 16:15:57 7277 [Note] InnoDB: Waiting for purge to start
2014-03-10 16:15:57 7277 [Note] InnoDB: 5.6.16 started; log sequence number 1625977
2014-03-10 16:15:57 7277 [Note] Binlog end
2014-03-10 16:15:57 7277 [Note] InnoDB: FTS optimize thread exiting.
2014-03-10 16:15:57 7277 [Note] InnoDB: Starting shutdown...
2014-03-10 16:15:59 7277 [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

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.

[clebeg@localhost mysql]$ sudo rpm -ivh MySQL-client-5.6.16-1.linux_glibc2.5.i386.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]




第五步:启动Mysql服务


[clebeg@localhost mysql]$ sudo /etc/init.d/mysql start
Starting MySQL. SUCCESS! 
[clebeg@localhost mysql]$ mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


PS:忘记root用户密码怎么办?

1:打开Mysql的安全模式

[clebeg@localhost mysql]$ sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 

2:接下来按照下面方式进入Mysql,修改密码即可

[clebeg@localhost mysql]$ mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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> UPDATE user SET Password=PASSWORD('your_new_passwd') where USER='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD('your_new_passwd');

最后大公告成!你可以好好的享受这个很好的数据库了!



          
展开阅读全文

没有更多推荐了,返回首页