centos6.4 rpm mysql安装步骤
1,检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称)
[root@localhost ~]# rpm -qa | grep -i mysql mysql-libs-5.1.66-2.el6_3.x86_64 [root@localhost ~]# yum -y remove mysql-libs*
2,删除掉系统中原有的数据,不然可以导致错误,我实际安装过程中试了几个小时,如果还有错,请参考
mv /var/lib/mysql /var/lib/mysql_old
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). [Note] Plugin ‘FEDERATED‘ is disabled. [Note] InnoDB: The InnoDB memory heap is disabled [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins [Note] InnoDB: Compressed tables use zlib 1.2.3 [Note] InnoDB: CPU does not support crc32 instructions [Note] InnoDB: Using Linux native AIO [Note] InnoDB: Initializing buffer pool, size = 128.0M [Note] InnoDB: Completed initialization of buffer pool [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages! [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data! [ERROR] Plugin ‘InnoDB‘ init function returned error. [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed. [ERROR] Unknown/unsupported storage engine: InnoDB [ERROR] Aborting [Note] Binlog end [Note] Shutting down plugin ‘partition‘ [Note] Shutting down plugin ‘BLACKHOLE‘ [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA‘ [Note] Shutting down plugin ‘ARCHIVE‘ [Note] Shutting down plugin ‘INNODB_SYS_DATAFILES‘ [Note] Shutting down plugin ‘INNODB_SYS_TABLESPACES‘ [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN_COLS‘ [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN‘ [Note] Shutting down plugin ‘INNODB_SYS_FIELDS‘ [Note] Shutting down plugin ‘INNODB_SYS_COLUMNS‘ [Note] Shutting down plugin ‘INNODB_SYS_INDEXES‘ [Note] Shutting down plugin ‘INNODB_SYS_TABLESTATS‘ [Note] Shutting down plugin ‘INNODB_SYS_TABLES‘ [Note] Shutting down plugin ‘INNODB_FT_INDEX_TABLE‘ [Note] Shutting down plugin ‘INNODB_FT_INDEX_CACHE‘ [Note] Shutting down plugin ‘INNODB_FT_CONFIG‘ [Note] Shutting down plugin ‘INNODB_FT_BEING_DELETED‘ [Note] Shutting down plugin ‘INNODB_FT_DELETED‘ [Note] Shutting down plugin ‘INNODB_FT_INSERTED‘ [Note] Shutting down plugin ‘INNODB_FT_DEFAULT_STOPWORD‘ [Note] Shutting down plugin ‘INNODB_METRICS‘ [Note] Shutting down plugin ‘INNODB_BUFFER_POOL_STATS‘ [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE_LRU‘ [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE‘ [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX_RESET‘ [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX‘ [Note] Shutting down plugin ‘INNODB_CMPMEM_RESET‘ [Note] Shutting down plugin ‘INNODB_CMPMEM‘ [Note] Shutting down plugin ‘INNODB_CMP_RESET‘ [Note] Shutting down plugin ‘INNODB_CMP‘ [Note] Shutting down plugin ‘INNODB_LOCK_WAITS‘ [Note] Shutting down plugin ‘INNODB_LOCKS‘ [Note] Shutting down plugin ‘INNODB_TRX‘ [Note] Shutting down plugin ‘MRG_MYISAM‘ [Note] Shutting down plugin ‘MEMORY‘ [Note] Shutting down plugin ‘CSV‘ [Note] Shutting down plugin ‘MyISAM‘ [Note] Shutting down plugin ‘sha256_password‘ [Note] Shutting down plugin ‘mysql_old_password‘ [Note] Shutting down plugin ‘mysql_native_password‘ [Note] Shutting down plugin ‘binlog‘ [Note] /usr/sbin/mysqld: Shutdown complete mysqld_safe mysqld from pid file /var/lib/mysql/mysql.pid ended
2,下载Linux对应的RPM包,如:CentOS6.4_32对应的RPM包,如下:
-rwxr--r--. 1 nobody nobody 22838580 Mar 17 17:39 MySQL-client-5.6.17-1.linux_glibc2.5.i386.rpm -rwxr--r--. 1 nobody nobody 4135464 Mar 17 17:40 MySQL-devel-5.6.17-1.linux_glibc2.5.i386.rpm -rwxr--r--. 1 nobody nobody 109826437 Mar 17 17:40 MySQL-embedded-5.6.17-1.linux_glibc2.5.i386.rpm -rwxr--r--. 1 nobody nobody 87469456 Mar 17 17:41 MySQL-server-5.6.17-1.linux_glibc2.5.i386.rpm -rwxr--r--. 1 nobody nobody 2362688 Mar 17 17:41 MySQL-shared-5.6.17-1.linux_glibc2.5.i386.rpm -rwxr--r--. 1 nobody nobody 5294221 Mar 17 17:41 MySQL-shared-compat-5.6.17-1.linux_glibc2.5.i386.rpm -rwxr--r--. 1 nobody nobody 74163863 Mar 17 17:41 MySQL-test-5.6.17-1.linux_glibc2.5.i386.rpm
3, 安装mysl
[root@localhost rpm]# rpm -ivh MySQL-server-5.6.15-1.el6.x86_64.rpm [root@localhost rpm]# rpm -ivh MySQL-devel-5.6.15-1.el6.x86_64.rpm [root@localhost rpm]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm #修改配置文件位置 [root@localhost rpm]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
4,初使化MYSQL及配置密码
[root@localhost rpm]# /usr/bin/mysql_install_db [root@localhost rpm]# service mysql start [root@localhost rpm]# cat /root/.mysql_secret #查看root账号密码 # The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl [root@localhost ~]# mysql -uroot –pqKTaFZnl mysql> SET PASSWORD = PASSWORD(‘123456‘); #设置密码为123456 mysql> exit [root@localhost ~]# mysql -uroot -p123456
5,允许远程登录
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> select host,user,password from user; +-----------------------+------+-------------------------------------------+ | host | user | password | +-----------------------+------+-------------------------------------------+ | localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | | localhost.localdomain | root | *A4B8196FF869F64E0119B231785E5946EDBA5E26 | | 127.0.0.1 | root | *A4B8196FF869F64E0119B231785E5946EDBA5E26 | | ::1 | root | *A4B8196FF869F64E0119B231785E5946EDBA5E26 | +-----------------------+------+-------------------------------------------+ 4 rows in set (0.00 sec) mysql> update user set password=password(‘root‘) where user=‘root‘; Query OK, 3 rows affected (0.01 sec) Rows matched: 4 Changed: 3 Warnings: 0 mysql> update user set host=‘%‘ where user=‘root‘ and host=‘localhost‘; Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
6,设置开机自启动
[root@localhost ~]# chkconfig mysql on [root@localhost ~]# chkconfig --list | grep mysql mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7,查看mysql配置文件位置
mysqld --verbose --help | grep -A 1 ‘Default options‘
8,MYSQL默认安装位置
/var/lib/mysql/ #数据库目录 /usr/share/mysql #配置文件目录 /usr/bin #相关命令目录 /etc/init.d/mysql #启动脚本
9,配置字符集
修改字符集和数据存储路径
配置/etc/my.cnf文件,修改数据存放路径、mysql.sock路径以及默认编码utf-8.
[client] password = 123456 port = 3306 default-character-set=utf8 [mysqld] port = 3306 character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci #(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写) lower_case_table_names=1 #(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; ) max_connections=1000 [mysql] default-character-set = utf8
查看字符集
show variables like ‘%collation%‘;
show variables like ‘%char%‘;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。