mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
# find user
mysql> select distinct user from mysql.user;
+-------+
| user |
+-------+
| myone |
| root |
| |
+-------+
3 rows in set (0.00 sec)
## needs the tick
mysql> create user mytwo identified by mypassword;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mypassword' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mypassword' at line 1
## create user successfully.
mysql> create user mytwo identified by 'mypassword';;
Query OK, 0 rows affected (0.00 sec)
#new user created
mysql> select distinct user from mysql.user;
+-------+
| user |
+-------+
| myone |
| mytwo |
| root |
| |
+-------+
4 rows in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
#new user created
mysql> select distinct user from mysql.user;
+-------+
| user |
+-------+
| myone |
| mytwo |
| root |
| |
+-------+
4 rows in set (0.00 sec)
#changing user password
mysql> set password for mytwo = password('mypassword123');
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
##drop user
mysql> drop user myone;
Query OK, 0 rows affected (0.00 sec)
## select user
mysql> select distinct user from mysql.user;
+-------+
| user |
+-------+
| mytwo |
| root |
| |
+-------+
3 rows in set (0.00 sec)
## rename user, Oracle can't do this.
mysql> rename user mytwo to myone;
Query OK, 0 rows affected (0.00 sec)
## verify user has been renamed.
Query OK, 0 rows affected (0.00 sec)
## select user
mysql> select distinct user from mysql.user;
+-------+
| user |
+-------+
| mytwo |
| root |
| |
+-------+
3 rows in set (0.00 sec)
## rename user, Oracle can't do this.
mysql> rename user mytwo to myone;
Query OK, 0 rows affected (0.00 sec)
## verify user has been renamed.
mysql> select distinct user from mysql.user;
+-------+
| user |
+-------+
| myone |
| root |
| |
+-------+
3 rows in set (0.00 sec)
+-------+
| user |
+-------+
| myone |
| root |
| |
+-------+
3 rows in set (0.00 sec)
## where all history stored.
$HOME/.mysql_history
mysqld - works in any platform. It just startup mysql
No comments:
Post a Comment