Centos 下彻底重装 Mysql

来源:互联网 发布:js代码格式化插件 编辑:程序博客网 时间:2024/05/21 17:39

环境介绍:

[root@localhost ~]# uname -aLinux 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/issueCentOS release 6.4 (Final)Kernel \r on an \m 


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

[clebeg@localhost download]$ lsMySQL-5.6.16-1.linux_glibc2.5.i386.rpm-bundle.tar //该包已经集成sever、client等等[clebeg@localhost mysql]$ lsMySQL-client-5.6.16-1.linux_glibc2.5.i386.rpmMySQL-devel-5.6.16-1.linux_glibc2.5.i386.rpmMySQL-embedded-5.6.16-1.linux_glibc2.5.i386.rpmMySQL-server-5.6.16-1.linux_glibc2.5.i386.rpmMySQL-shared-5.6.16-1.linux_glibc2.5.i386.rpmMySQL-shared-compat-5.6.16-1.linux_glibc2.5.i386.rpmMySQL-test-5.6.16-1.linux_glibc2.5.i386.rpm 


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

[clebeg@localhost mysql]$ sudo netstat -tap | grep mysqltcp        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 pages2014-03-10 16:15:47 7248 [Note] InnoDB: The InnoDB memory heap is disabled2014-03-10 16:15:47 7248 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation2014-03-10 16:15:47 7248 [Note] InnoDB: Compressed tables use zlib 1.2.32014-03-10 16:15:47 7248 [Note] InnoDB: Using Linux native AIO2014-03-10 16:15:47 7248 [Note] InnoDB: Not using CPU crc32 instructions2014-03-10 16:15:47 7248 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-03-10 16:15:47 7248 [Note] InnoDB: Completed initialization of buffer pool2014-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 MB2014-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 MB2014-03-10 16:15:48 7248 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2014-03-10 16:15:49 7248 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02014-03-10 16:15:49 7248 [Warning] InnoDB: New log files created, LSN=457812014-03-10 16:15:49 7248 [Note] InnoDB: Doublewrite buffer not found: creating new2014-03-10 16:15:49 7248 [Note] InnoDB: Doublewrite buffer created2014-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 created2014-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 start2014-03-10 16:15:50 7248 [Note] InnoDB: 5.6.16 started; log sequence number 0A random root password has been set. You will find it in '/root/.mysql_secret'.2014-03-10 16:15:55 7248 [Note] Binlog end2014-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 16259772014-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 pages2014-03-10 16:15:57 7277 [Note] InnoDB: The InnoDB memory heap is disabled2014-03-10 16:15:57 7277 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation2014-03-10 16:15:57 7277 [Note] InnoDB: Compressed tables use zlib 1.2.32014-03-10 16:15:57 7277 [Note] InnoDB: Using Linux native AIO2014-03-10 16:15:57 7277 [Note] InnoDB: Not using CPU crc32 instructions2014-03-10 16:15:57 7277 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-03-10 16:15:57 7277 [Note] InnoDB: Completed initialization of buffer pool2014-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 start2014-03-10 16:15:57 7277 [Note] InnoDB: 5.6.16 started; log sequence number 16259772014-03-10 16:15:57 7277 [Note] Binlog end2014-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 1625987A 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_installationwhich 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.comSupport MySQL by buying support/licenses at http://shop.mysql.comWARNING: 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 startStarting MySQL. SUCCESS! [clebeg@localhost mysql]$ mysql -u root -pEnter 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 mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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: 0mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)mysql> quitERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> show databases;ERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> SET PASSWORD = PASSWORD('your_new_passwd');

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


                                             
0 0
原创粉丝点击