Question : mysql installation,configuration in linux

mysql installation,configuration and basic security in linux

Answer : mysql installation,configuration in linux

1. Depending on the distribution that you run, you can install MySQL client and server applications with packet managers:

RedHat / Fedora / CentOS:
# yum install mysql mysql-server

Debian, Ubuntu:
# apt-get install mysql-client mysql-server

2. If you want MySQL to be started at boot run:

RedHat / Fedora / CentOS:
# chkconfig mysqld on

Debian, Ubuntu:
# update-rc.d mysql defaults

3. Configuration:


/etc/my.cnf is the main configuration file, and for basic configuration you maybe want to make it listen only on localhost (disallow remote access) with:

bind-address=127.0.0.1

Now, start the service:

RedHat / Fedora / CentOS:
# service mysqld start

Debian, Ubuntu:
# /etc/init.d/mysql start


MySQL comes with open root access so you should set the root password, with mysqladmin client utility;

# mysqladmin -u root password new-password

You can create a database:

# mysqladmin -h localhost -u root -ppassword create your_database_name

If you want to add a user that will have some access to that database you've just created use mysql command. MySQL has a client utility with which you can access and use it in a CLI fashion. To add a user, and give him some privileges use:

# mysql -u root -h localhost -ppassword your_database_name
mysql>
 GRANT ALL PRIVILEGES ON your_database_name.* TO username@localhost IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;

It is good to know that MySQL stores its user information in a database called mysql.

You can backup the database with:

#
mysqldump --add-drop-table -u username -ppassword database_name > backup_file

MySQL uses TCP port 3306, so you could use iptables to restrict access for some remote networks.
Random Solutions  
 
programming4us programming4us