Requirement :
- No special requirement.
Primary steps :
- Install mysql with yum command.
- First time starting and config.
- Populate with some data.
Steps in detail :
1. Install mysql :
Check if the mysql-server has been installed ?Server# rpm -qa | grep mysql-server
If not, install it.
Dependencies Resolved
=================================================================
Package Arch Version Repository Size
=================================================================
Installing:
mysql-server i686 5.1.61-4.el6 base 8.8 M
Installing for dependencies:
mysql i686 5.1.61-4.el6 base 892 k
perl-DBD-MySQL i686 4.013-3.el6 base 134 k
perl-DBI i686 1.609-4.el6 base 705 k
Updating for dependencies:
mysql-libs i686 5.1.61-4.el6 base 1.2 M
Transaction Summary
=================================================================
Install 4 Package(s)
Upgrade 1 Package(s)
Total download size: 12 M
2. Config the mysql service.
When done, it will ask you to set the root password !!!
Server# /etc/init.d/mysqld start
Initializing MySQL database:
Set the mysql root password. Replace the 'secret' with you real password.
Server# /usr/bin/mysqladmin -u root password secret
Try login with the new password.
Server# mysql -u root -p'secret'
Search for some sample config files.
Server# rpm -ql mysql-server | grep cnf
/usr/share/doc/mysql-server-5.1.61/my-huge.cnf
According to your server configuration, pick up the approriate config file and paste it to the /etc/my.cnf.
In my case, I used the my-huge.cnf
Server# vim /etc/my.cnf
[mysqld]
mysql> create database sample;
Initializing MySQL database:
Installing MySQL system tables... OK
Filling help tables... OK
To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h VMhost password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation which will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr;/usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!
Starting mysqld: [ OK ]
Server# /usr/bin/mysqladmin -u root password secret
Try login with the new password.
Server# mysql -u root -p'secret'
Search for some sample config files.
Server# rpm -ql mysql-server | grep cnf
/usr/share/doc/mysql-server-5.1.61/my-huge.cnf
/usr/share/doc/mysql-server-5.1.61/my-innodb-heavy-4G.cnf
/usr/share/doc/mysql-server-5.1.61/my-large.cnf
/usr/share/doc/mysql-server-5.1.61/my-medium.cnf
/usr/share/doc/mysql-server-5.1.61/my-small.cnf
According to your server configuration, pick up the approriate config file and paste it to the /etc/my.cnf.In my case, I used the my-huge.cnf
[mysqld]
skip-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
Restart the service for apply the new config.
Server# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
Login to the mysql console :
Server# mysql -u root -p'secret'
Server# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
3. Populate with some data.
Let's create a sample database with one table account and some sample records.Login to the mysql console :
Server# mysql -u root -p'secret'
No comments:
Post a comment