Difference between revisions of "SBN - Database Server Notes"

From The TinkerNet Wiki
Jump to navigation Jump to search
Line 5: Line 5:
 
i.e.: Wikipedia, WordPress, WeeWX, etc...
 
i.e.: Wikipedia, WordPress, WeeWX, etc...
  
= Linux Mint =
+
=Linux Mint=
* Mint 19.3 Seems to get MySQL 5.7.30
 
* Mint 20 Gets MySQL 8.0.20
 
  
* <code>sudo apt install mysql-server mysql-client php-mysql</code>
+
*Mint 19.3 Seems to get MySQL 5.7.30
** Say Yes to Continue
+
*Mint 20 Gets MySQL 8.0.20
* See [[TinkerWiki:MySQL - Initial Configuration]] for configuration
 
  
= SparkyLinux =
+
*<code>sudo apt install mysql-server mysql-client php-mysql</code>
* Doesn't even have MySQL in the repositories...
+
**Say Yes to Continue
* [[TinkerWiki:Getting MySQL onto SparkyLinux]]
+
*See [[MySQL - Initial Configuration]] for configuration
** Which then gets MySQL 8.0.21
 
  
* <code>sudo apt install mysql-server mysql-client php-mysql</code>
+
=SparkyLinux=
** Say Yes to Continue
 
** <u>Configuring mysql-community-server</u>
 
*** Pick a good '''root''' password...
 
*** I tend to select '''Use Legacy Authentication Method''' because '''Use Strong Password Encryption''' is annoying as hell.  (Your choice here...)
 
* See [[TinkerWiki:MySQL - Initial Configuration B]] for configuration
 
** (pretty much same as [[TinkerWiki:MySQL - Initial Configuration]] except the root password is already done...)
 
  
= Set up at least one user in mysql =
+
*Doesn't even have MySQL in the repositories...
 +
*[[Getting MySQL onto SparkyLinux]]
 +
**Which then gets MySQL 8.0.21
  
* <code>sudo mysql -u root -p</code>
+
*<code>sudo apt install mysql-server mysql-client php-mysql</code>
** You will be asked for '''2''' passwords, your own & that of the root database user.
+
**Say Yes to Continue
 +
**<u>Configuring mysql-community-server</u>
 +
***Pick a good '''root''' password...
 +
***I tend to select '''Use Legacy Authentication Method''' because '''Use Strong Password Encryption''' is annoying as hell.  (Your choice here...)
 +
*See [[MySQL - Initial Configuration B]] for configuration
 +
**(pretty much same as [[MySQL - Initial Configuration]] except the root password is already done...)
 +
 
 +
=Set up at least one user in mysql=
 +
 
 +
*<code>sudo mysql -u root -p</code>
 +
**You will be asked for '''2''' passwords, your own & that of the root database user.
  
 
  CREATE USER 'someone'@'localhost' IDENTIFIED BY 'password';
 
  CREATE USER 'someone'@'localhost' IDENTIFIED BY 'password';
Line 36: Line 38:
 
('''Hint:'''  This'd be a good time to create yourself as that user with your non-admin password of choice...)
 
('''Hint:'''  This'd be a good time to create yourself as that user with your non-admin password of choice...)
  
If this is to be a remotely accessed Database Server, ''''localhost'''' will actually be the name/address of the remote machine you'll access '''from'''. (Possibly even ''''*'''')
+
If this is to be a remotely accessed Database Server, '<nowiki/>'''localhost'<nowiki/>''' will actually be the name/address of the remote machine you'll access '''from'''. (Possibly even '<nowiki/>'''*'''')
  
= Reference Materials =
+
=Reference Materials=
  
* [http://g2pc1.bu.edu/~qzpeng/manual/MySQL%20Commands.htm Commands]
+
*[http://g2pc1.bu.edu/~qzpeng/manual/MySQL%20Commands.htm Commands]
* [https://linuxize.com/post/how-to-manage-mysql-databases-and-users-from-the-command-line/ How to Manage MySQL Databases and Users from the Command Line]
+
*[https://linuxize.com/post/how-to-manage-mysql-databases-and-users-from-the-command-line/ How to Manage MySQL Databases and Users from the Command Line]
* [https://www.hostinger.com/tutorials/?s=mysql Some handy tutorials]
+
*[https://www.hostinger.com/tutorials/?s=mysql Some handy tutorials]
** [https://www.hostinger.com/tutorials/mysql-show-users/ How to Show Users in MySQL on Linux]
+
**[https://www.hostinger.com/tutorials/mysql-show-users/ How to Show Users in MySQL on Linux]
  
= Useful Things =
+
=Useful Things=
  
* Restart MySQL
+
*Restart MySQL
** <code>sudo systemctl restart mysql.service</code>
+
**<code>sudo systemctl restart mysql.service</code>
* Change a user password
+
*Change a user password
** <code>ALTER USER 'userName'@'localhost' IDENTIFIED BY 'New-Password-Here';</code>
+
**<code>ALTER USER 'userName'@'localhost' IDENTIFIED BY 'New-Password-Here';</code>
* Trash a complete database '''(WARNING! DANGER! DAMAGE LIKELY!)'''
+
*Trash a complete database '''(WARNING! DANGER! DAMAGE LIKELY!)'''
** <code>DROP DATABASE wp_Someblog;</code>
+
**<code>DROP DATABASE wp_Someblog;</code>
* List existing databases
+
*List existing databases
** <code>SHOW databases;</code>
+
**<code>SHOW databases;</code>
* List existing users
+
*List existing users
** <code>SELECT user,host FROM mysql.user;</code>
+
**<code>SELECT user,host FROM mysql.user;</code>

Revision as of 16:44, 18 July 2020

A dedicated server Just to run MySQL...

Then you can simply point all the other things that use it to a central location.

i.e.: Wikipedia, WordPress, WeeWX, etc...

Linux Mint

  • Mint 19.3 Seems to get MySQL 5.7.30
  • Mint 20 Gets MySQL 8.0.20

SparkyLinux

  • sudo apt install mysql-server mysql-client php-mysql
    • Say Yes to Continue
    • Configuring mysql-community-server
      • Pick a good root password...
      • I tend to select Use Legacy Authentication Method because Use Strong Password Encryption is annoying as hell. (Your choice here...)
  • See MySQL - Initial Configuration B for configuration

Set up at least one user in mysql

  • sudo mysql -u root -p
    • You will be asked for 2 passwords, your own & that of the root database user.
CREATE USER 'someone'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

(Hint: This'd be a good time to create yourself as that user with your non-admin password of choice...)

If this is to be a remotely accessed Database Server, 'localhost' will actually be the name/address of the remote machine you'll access from. (Possibly even '*')

Reference Materials

Useful Things

  • Restart MySQL
    • sudo systemctl restart mysql.service
  • Change a user password
    • ALTER USER 'userName'@'localhost' IDENTIFIED BY 'New-Password-Here';
  • Trash a complete database (WARNING! DANGER! DAMAGE LIKELY!)
    • DROP DATABASE wp_Someblog;
  • List existing databases
    • SHOW databases;
  • List existing users
    • SELECT user,host FROM mysql.user;