Install MySQL
- In stall MySQL:
sudo apt-get update
sudo apt-get install mysql-server - Set the root password
- Secure it:
sudo mysql_secure_installation
Answer the questions including disallowing root remote login - Test it:
service mysql status
mysqladmin -p -u root version
Create New MySQL User
- Start a mysql session:
mysql -u root -p - Show existing users:
SELECT User FROM mysql.user; - Create a new User:
CREATE USER '<newuser>'@'localhost' IDENTIFIED BY '<password>';
NB: Change password:
Requirements: >8 chars; upper and lower case; special chars e.g. "!"
shell: mysql --host=localhost --user=<user> --password=<password> <datbase>
mysql> use mysql;
mysql> SET PASSWORD FOR '<username>'@'<hostname>' = PASSWORD('<password>');
Requirements: >8 chars; upper and lower case; special chars e.g. "!"
shell: mysql --host=localhost --user=<user> --password=<password> <datbase>
mysql> use mysql;
mysql> SET PASSWORD FOR '<username>'@'<hostname>' = PASSWORD('<password>');
Create New Database
e.g. for Zabbix monitoring tool (from official documentation):
- Start a mysql session:
mysql -u root -p - Show existing databases:
SHOW DATABASES; - Create the Database:
create database zabbix character set utf8 collate utf8_bin; - Grant Permissions to user 'zabbix':
GRANT ALL PRIVILEGES ON zabbix.* to zabbix@localhost identified by '<password>'; - Flush the privileges:
FLUSH PRIVILEGES;
No comments:
Post a Comment