الجمعة، 17 سبتمبر 2010

Install and Configure MySQL Perform the configuration of MySQL after Installing

MySQL is a database storage engine, the most use for php site/script/applications. Here, I will installing an optimized version with more basic security pre-cautions.Installing libpthread
cd /usr/ports/devel/libpthread-stubs/make install clean
Installing MySQL
cd /usr/ports/databases/mysql51-server/make -D BUILD_OPTIMIZED=yes BUILD_STATIC=yes WITH_PROC_SCOPE_PTH=yes install clean
Copyng config file and MySQL files
cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf
This is a template of my.cnf, will help to keep the MySQL secure.Make sure you leave skip-networking and set-variable=local-infile=0 in your config file.
[mysqld]#skip-name-resolvesafe-show-database#old_passwordsback_log = 50skip-innodbmax_connections = 500key_buffer_size = 128Mmyisam_sort_buffer_size = 128Mjoin_buffer_size = 1Mread_buffer_size = 1Msort_buffer_size = 4Mtable_cache = 5000thread_cache_size = 256wait_timeout = 20connect_timeout = 30tmp_table_size = 128Mmax_heap_table_size = 64Mmax_allowed_packet = 64Mnet_buffer_length = 16384max_connect_errors = 10thread_concurrency = 2concurrent_insert = 2table_lock_wait_timeout = 30read_rnd_buffer_size = 786432bulk_insert_buffer_size = 8Mquery_cache_limit = 6Mquery_cache_size = 128Mquery_cache_type = 1query_prealloc_size = 262144query_alloc_block_size = 65536transaction_alloc_block_size = 8192transaction_prealloc_size = 4096default-storage-engine = MyISAMmax_write_lock_count = 16skip-networkingset-variable=local-infile=0[mysqld_safe]nice = -10open_files_limit = 8192[mysqldump]quickmax_allowed_packet = 16M[myisamchk]key_buffer = 384Msort_buffer = 64Mread_buffer = 16Mwrite_buffer = 16M 
Setup the MySQL
mysql_install_db --user=mysqlchown -R mysql /var/db/mysql/chgrp -R mysql /var/db/mysql//usr/local/bin/mysqld_safe -user=mysql &exit 
Open /etc/rc.conf and add
mysql_enable="YES"
Starting MySQL
/usr/local/etc/rc.d/mysql-server start
Change the root password of MySQL
/usr/local/bin/mysqladmin -u root password 'newpassword'
For login as root
mysql -u root -p
Optional: Deleting the test databasemysql>
drop database test;mysql> use mysql;mysql> delete from db;mysql> delete from user where not (host="localhost" and user="root");mysql> flush privileges;
To make more secure the MySQL administration, change the root username for MySQL
mysql> update user set user="sqladmindatabase" where user="root";mysql> flush privileges;
installing the php extensions for open connection between php and mysql
cd /usr/ports/databases/php5-mysql/make install cleancd /usr/ports/databases/php5-mysqli/make install clean
Restarting php-fpm
/usr/local/etc/rc.d/php-fpm restart
Clean last command of MySQL
cat /dev/null > ~/.mysql_history
Now the Database MySQL are correctly installed, configured and Optimized ;)

ليست هناك تعليقات:

إرسال تعليق