MYSQL common command analysis (1)

xiaoxiao2021-03-05  21

After installed RedHat9, I already installed mySQL, to the online Down a C connected to Mysql's simple program mysql.c to compile: GCC mysql.c -l / usr / lib / mysql -lmysqlclient -lz -o mysql, where -L The parameters behind are the MySQL library directory, which may vary for different versions of Redhat, you can use the lookup command to search. There are many friends who have installed mySQL but I don't know how to use it. In this article we learn some of the common commands of MySQL from connecting MySQL, modifying passwords, increasing users. First, connect mysql. Format: MySQL -H Host Address -u User Name -P User Password 1, Example 1: Connect to MySQL on the unit. First open the DOS window, then enter the directory mysql / bin, then type the command mysql -uroot -p, then prompt you to lose your password, if you just install MySQL, the superuser root is no password, so it can be used directly Going into MySQL, MySQL's prompt is: mysql>. Note: If you do not write -p, the system does not use the password by default, so if you need to enter your password, you must specify mysql -u root -p, and then enter. 2, Example 2: Connect to MySQL on the remote host. Suppose the IP of the remote host is: 110.110.110.110, the username is root, the password is ABCD123. Then type the following command: mysql -h110.110.110.110 -uroot -Pabcd123 (Note: u and root can not have a splings, others have two systems on my machine, WINDOWS does not support remote login to Linux Tip: "Host '192.168.0.16' is not allowed to connect to this mysql server" I don't know where it can be set? ! But you can remotely access Windows MySQL databases remotely under Linux. 3, exit the mysql command: EXIT (Enter) Second, modify the password. Format: mysqladmin -u User Name -P Old Password Password New Password 1, Example 1: Add a password to the root AB12. First enter the directory mysqlbin under DOS, then type the following command mysqladmin -uroot password AB12 Note: Because the root does not have a password, the -p old password can be omitted. 2, Example 2: Change the root password to DJG345. MySQLADMIN -UROOT Password DJG345 -P Password: AB12 Note: Any user can be accessed without password under my Linux (including users do not exist, only casually knocking some letters), but only read-only privileges. There is an exception: When using the program to connect the database, Mysql_Real_Connect, you must specify the username and password, and anonymous logins is in love.

转载请注明原文地址:https://www.9cbs.com/read-36154.html

New Post(0)