Install and configure mysql in linux
Install mysql 1 using yum in linux. mysql Installation check whether the old mysql version has been installed: yum list installed mysql * rpm-qa | grep mysql * install mysqlyum install mysql-servermysql-devel mysql note: here the default yum source can only be installed in the mysql-5.1.73-3.el6_5.x86_64 version, to install the latest mysql database, you need to use another installation Source
Ii. Install MySQL 5.5.x
1. Install MySQL 5.5.x yum Source:
Rpm-Uvh http://repo.webtatic.com/yum/CentOS/5/latest.rpm
2. Install the MySQL client support package:
Yum install libmysqlclient15 -- enablerepo = webtatic
3. Uninstall the software packages of earlier MySQL versions:
Yum remove mysql -*
4. Install the MySQL 5.5 client and server:
Yum install mysql55 mysql55-server -- enablerepo = webtatic // -- enablerepo = webtatic specifies to use the yum source downloaded in step 1 to download and install
Note: During yum installation, the missing lib may be reported. Install the required lib library as required.
3. start mysql and stop mysql service: service mysqld start or/etc/init. d/mysqld start:
Chkconfig-add mysqld to check whether the startup setting is successful. chkconfig -- list | grep mysql * stop: service mysqld stop 4. basic configuration
1. Modify the root administrator password: mysqladmin-u root password "the password you want to set"
2. Set remote access to mysql to add permissions: the user table in the mysql database adds a record with host as "%" and user as "root ".
Grantallon *. * to 'root' @ '% ';
Flush privileges; 3. Several important MySQL directories default database directories, which can be modified by yourself
/Var/lib/mysql/
Mysql Log File
/Var/log/mysql. log (by default)
Configuration file/etc/my. cnf
Attach my. cnf for your reference
- [client]
- socket=/var/lib/mysql/mysql.sock
- default-character-set=utf8
- [client]
- socket=/var/lib/mysql/mysql.sock
- default-character-set=utf8
- [mysqld]
- innodb_file_per_table=1
- default-character-set=utf8
- init_connect='SET NAMES utf8'
- datadir=/database/mysql
- socket=/var/lib/mysql/mysql.sock
- skip-external-locking
- user=mysql
- general_log_file=/database/mysql/log/mysql.log
- long_query_time=1
- slow_query_log=1
- slow_query_log_file=/database/mysql/log/slowquery.log
- key_buffer_size = 128M
- max_allowed_packet = 1M
- table_open_cache = 512
- sort_buffer_size = 4M
- read_buffer_size = 2M
- read_rnd_buffer_size = 8M
- myisam_sort_buffer_size = 64M
- thread_cache_size = 8
- query_cache_size = 32M
- query_prealloc_size = 64M
- join_buffer_size = 128M
- # Default to using old password format for compatibility with mysql 3.x
- # clients (those using the mysqlclient10 compatibility package).
- old_passwords=1
- # Disabling symbolic-links is recommended to prevent assorted security risks;
- # to do so, uncomment this line:
- # symbolic-links=0
- innodb_buffer_pool_size=64M
- [mysqld_safe]
- log-error=/database/mysql/log/mysql.error.log
- pid-file=/var/run/mysqld/mysqld.pid
- [myisamchk]
- key_buffer_size = 128M
- sort_buffer_size = 128M
- read_buffer = 2M
- write_buffer = 2M