首页 > 数据库 > MySQL > mysql的rpm包安装
1、准备好安装包:
[root@dba ~]# ll
总用量 75916
-rw-------. 1 root root 1647 6月 24 11:29 anaconda-ks.cfg
-rw-r--r--. 1 root root 45675 6月 24 11:29 install.log
-rw-r--r--. 1 root root 10033 6月 24 11:27 install.log.syslog
-rw-r--r--. 1 root root 356 7月 10 13:55 list
-rw-r--r-- 1 root root 18520600 7月 14 10:45 MySQL-client-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 3414856 7月 14 10:45 MySQL-devel-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 55680608 7月 14 10:45 MySQL-server-5.6.23-1.el6.x86_64.rpm
2、安装服务器端提示包冲突:
[root@dba ~]# rpm -ivh MySQL-server-5.6.23-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.23-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.23-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.23-1.el6.x86_64 conflicts with fi
3、删除冲突的包依赖:
[root@dba ~]# yum -y remove mysql-libs-5.1.66-2.el6_3.x86_64
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.66-2.el6_3 will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
4、重装mysql服务端:
[root@dba ~]# rpm -ivh MySQL-server-5.6.23-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2015-07-14 10:59:02 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-07-14 10:59:02 1953 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-07-14 10:59:02 1953 [Note] InnoDB: The InnoDB memory heap is disabled
2015-07-14 10:59:02 1953 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-07-14 10:59:02 1953 [Note] InnoDB: Memory barrier is not used
2015-07-14 10:59:02 1953 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-07-14 10:59:02 1953 [Note] InnoDB: Using Linux native AIO
2015-07-14 10:59:02 1953 [Note] InnoDB: Not using CPU crc32 instructions
2015-07-14 10:59:02 1953 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-07-14 10:59:02 1953 [Note] InnoDB: Completed initialization of buffer pool
2015-07-14 10:59:02 1953 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-07-14 10:59:02 1953 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-07-14 10:59:02 1953 [Note] InnoDB: Database physically writes the file full: wait...
2015-07-14 10:59:04 1953 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-07-14 10:59:07 1953 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-07-14 10:59:08 1953 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-07-14 10:59:08 1953 [Warning] InnoDB: New log files created, LSN=45781
2015-07-14 10:59:08 1953 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-07-14 10:59:08 1953 [Note] InnoDB: Doublewrite buffer created
2015-07-14 10:59:08 1953 [Note] InnoDB: 128 rollback segment(s) are active.
2015-07-14 10:59:08 1953 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-07-14 10:59:08 1953 [Note] InnoDB: Foreign key constraint system tables created
2015-07-14 10:59:08 1953 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-07-14 10:59:08 1953 [Note] InnoDB: Tablespace and datafile system tables created.
2015-07-14 10:59:08 1953 [Note] InnoDB: Waiting for purge to start
2015-07-14 10:59:08 1953 [Note] InnoDB: 5.6.23 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2015-07-14 10:59:09 1953 [Note] Binlog end
2015-07-14 10:59:09 1953 [Note] InnoDB: FTS optimize thread exiting.
2015-07-14 10:59:09 1953 [Note] InnoDB: Starting shutdown...
2015-07-14 10:59:10 1953 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2015-07-14 10:59:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-07-14 10:59:10 1976 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-07-14 10:59:10 1976 [Note] InnoDB: The InnoDB memory heap is disabled
2015-07-14 10:59:10 1976 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-07-14 10:59:10 1976 [Note] InnoDB: Memory barrier is not used
2015-07-14 10:59:10 1976 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-07-14 10:59:10 1976 [Note] InnoDB: Using Linux native AIO
2015-07-14 10:59:10 1976 [Note] InnoDB: Not using CPU crc32 instructions
2015-07-14 10:59:10 1976 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-07-14 10:59:10 1976 [Note] InnoDB: Completed initialization of buffer pool
2015-07-14 10:59:10 1976 [Note] InnoDB: Highest supported file format is Barracuda.
2015-07-14 10:59:10 1976 [Note] InnoDB: 128 rollback segment(s) are active.
2015-07-14 10:59:10 1976 [Note] InnoDB: Waiting for purge to start
2015-07-14 10:59:10 1976 [Note] InnoDB: 5.6.23 started; log sequence number 1625977
2015-07-14 10:59:10 1976 [Note] Binlog end
2015-07-14 10:59:10 1976 [Note] InnoDB: FTS optimize thread exiting.
2015-07-14 10:59:10 1976 [Note] InnoDB: Starting shutdown...
2015-07-14 10:59:12 1976 [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
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
5、安装客户端和依赖包:
[root@dba ~]# rpm -ivh MySQL-client-5.6.23-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@dba ~]# rpm -ivh MySQL-devel-5.6.23-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
6、打开mysql服务:
[root@dba ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@dba ~]# service mysql start
Starting MySQL. SUCCESS!
[root@dba ~]# netstat -nat | grep 3306
tcp 0 0 :::3306 :::* LISTEN
7、停止服务:
[root@dba ~]# /etc/init.d/mysql stop
Shutting down MySQL.. SUCCESS!
8、登录mysql数据库:
[root@dba ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[2] 2308
[root@dba ~]# 150714 11:02:58 mysqld_safe Logging to '/var/lib/mysql/dba.fei.com.err'.
150714 11:02:58 mysqld_safe A mysqld process already exists
^C
[2]+ Exit 1 mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@dba ~]# 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.23 MySQL Community Server (GPL)
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>
9、忘记root密码的修改方法:
[root@dba my.cnf.d]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
增加:
skip-grant-tables
[root@dba my.cnf.d]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@dba my.cnf.d]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.23 MySQL Community Server (GPL)
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> USE mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password = password ('123456') WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
10、使用新密码登录数据库:
[root@dba my.cnf.d]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.23
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>
mysql> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> grant all on *.* to root@'%' identified by '123456';
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.01 sec)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29313086/viewspace-1732602/ ,如需转载,请注明出处,否则将追究法律责任。