Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:mysql [2017/01/12 18:48] alfred |
wiki2:mysql [2021/10/19 09:32] (actual) |
||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== MySQL ====== | ====== MySQL ====== | ||
| - | ===== Allow remote connections ===== | + | ===== Create users ===== |
| + | GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’; | ||
| + | |||
| + | <code> | ||
| + | mysql> CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass'; | ||
| + | mysql> GRANT ALL PRIVILEGES ON *.* TO 'finley'@'localhost' WITH GRANT OPTION; | ||
| + | </code> | ||
| + | Allow remote connections: | ||
| <code> | <code> | ||
| - | mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; | + | mysql> CREATE USER 'finley'@'%' IDENTIFIED BY 'some_pass'; |
| - | mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' | + | mysql> GRANT ALL PRIVILEGES ON *.* TO 'finley'@'%' WITH GRANT OPTION; |
| - | -> WITH GRANT OPTION; | + | |
| - | mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; | + | |
| - | mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' | + | |
| - | -> WITH GRANT OPTION; | + | |
| - | mysql> CREATE USER 'admin'@'localhost'; | + | |
| - | mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost'; | + | |
| - | mysql> CREATE USER 'dummy'@'localhost'; | + | |
| </code> | </code> | ||
| + | For example, lets create an access for the user 'mantis' with password 'mantis' only available to connect from 81.4.127.208 to the database mantis: | ||
| + | <code> | ||
| + | create user 'mantis'@'81.4.127.208' identified by 'mantis'; | ||
| + | grant all privileges on mantis.* to 'mantis'@'81.4.127.208' with grant option; | ||
| + | flush privileges; | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | FLUSH PRIVILEGES; | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | DROP USER ‘demo’@‘localhost’; | ||
| + | </code> | ||
| ===== Entrar por consola con user y password ===== | ===== Entrar por consola con user y password ===== | ||
| + | -h <host> | ||
| + | <code> | ||
| + | mysql -u root -h 127.0.0.1 -p | ||
| + | </code> | ||
| <code> | <code> | ||
| mysql -u root -ppassword | mysql -u root -ppassword | ||
| </code> | </code> | ||
| - | ===== Instalar la versión 5.6 ===== | + | ===== Ejecutar commando ===== |
| <code> | <code> | ||
| - | sudo apt-get install mysql-server-5.6 | + | mysql -u root -h 127.0.0.1 -ppassword -e "select * from users" |
| </code> | </code> | ||
| - | |||
| ===== Backups ===== | ===== Backups ===== | ||
| <code> | <code> | ||
| Línea 36: | Línea 54: | ||
| <code> | <code> | ||
| mysql database_name < database_name.sql | mysql database_name < database_name.sql | ||
| + | </code> | ||
| + | **Create a database and load an sql file on it:** | ||
| + | <code> | ||
| + | mysqladmin -u username -p"password" create newDbName | ||
| + | mysql -u username -p"password" newDbName < oldDbName.sql | ||
| </code> | </code> | ||
| <code> | <code> | ||
| mysql --one-database database_name < all_databases.sql | mysql --one-database database_name < all_databases.sql | ||
| </code> | </code> | ||