Ubuntu/mysql

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
Line 14: Line 14:
 
verify MySQL is running
 
verify MySQL is running
 
  sudo netstat -tap | grep mysql
 
  sudo netstat -tap | grep mysql
 +
determine MySQL version
 +
<nowiki>~$ mysql --version
 +
 +
or
 +
mysql> SELECT VERSION();
 +
+-------------------------+
 +
| VERSION()              |
 +
+-------------------------+
 +
| 5.1.73-0ubuntu0.10.04.1 |
 +
+-------------------------+
 +
1 row in set (0.00 sec)
 +
 +
or
 +
mysql> SHOW VARIABLES LIKE "%version%";
 +
+-------------------------+-------------------------+
 +
| Variable_name          | Value                  |
 +
+-------------------------+-------------------------+
 +
| protocol_version        | 10                      |
 +
| version                | 5.1.73-0ubuntu0.10.04.1 |
 +
| version_comment        | (Ubuntu)                |
 +
| version_compile_machine | i486                    |
 +
| version_compile_os      | debian-linux-gnu        |
 +
+-------------------------+-------------------------+
 +
5 rows in set (0.00 sec)</nowiki>
 
backup wiki mysql database
 
backup wiki mysql database
 
  sudo -s
 
  sudo -s

Revision as of 13:51, 5 August 2015

mysql is one of the most popular database applications on the market today


mysql login

mysql -u <user> -p

will then prompt you for a password
mysqladmin login

mysqladmin -u <user> -p

you can also run other commands after -p, such as:
see if the database is running

status

change MySQL root pass

sudo dpkg-reconfigure mysql-server-5.1

verify MySQL is running

sudo netstat -tap | grep mysql

determine MySQL version

~$ mysql --version

or
mysql> SELECT VERSION();
+-------------------------+
| VERSION()               |
+-------------------------+
| 5.1.73-0ubuntu0.10.04.1 |
+-------------------------+
1 row in set (0.00 sec)

or
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+-------------------------+
| Variable_name           | Value                   |
+-------------------------+-------------------------+
| protocol_version        | 10                      |
| version                 | 5.1.73-0ubuntu0.10.04.1 |
| version_comment         | (Ubuntu)                |
| version_compile_machine | i486                    |
| version_compile_os      | debian-linux-gnu        |
+-------------------------+-------------------------+
5 rows in set (0.00 sec)

backup wiki mysql database

sudo -s
mysqldump -u user -p db.name > wikidatabasebackup.sql
i.e. mysql -u wikiuser -p wikidb > /var/www/mediawiki/backup/wikidatabasebackup10_4_12.sql

view all databases

~$ mysql -u root -p
~mysql>SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema | 
+--------------------+
3 rows in set (0.00 sec)

delete (drop) a database

~mysql> DROP DATABASE IF EXISTS <db name>;
Query OK, 11 rows affected (0.04 sec)

list all users

~mysql> SELECT User,Host FROM mysql.user;
+------------------+-----------------+
| User             | Host            |
+------------------+-----------------+
| root             | 127.0.0.1       |
| root             | ::1             |
| root             | mysite |
| debian-sys-maint | localhost       |
| root             | localhost       |
+------------------+-----------------+
5 rows in set (0.00 sec)

delete a user

~mysql> DROP USER 'wordpress'@'localhost';
Query OK, 0 rows affected (0.00 sec)


Change a mysql user's password.
Login as root.

~$ mysql -u root -p

From the mysql console, select the mysql db (this is where mysql users are stored, like root)

~mysql> use mysql; 

Update the password. Make sure to replace your_new_password and changed_user with the appropriate values.

~$mysql> update user set password=PASSWORD('your_new_password') where User='changed_user';


Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox