service apache2 start service mysql start
And then again var/wwwxi Just write it down

Be a little girl demo bar

<?php $servername = "localhost"; $username = "root"; $password = "root";
$dbname = "shujuku"; // Create a connection $conn = new mysqli($servername, $username,
$password,$dbname); // Detect connections if ($conn->connect_error) { die(" connection failed : " .
$conn->connect_error); } echo " Connection successful "; $sql = "SELECT * FROM shujuku"; $result =
$conn->query($sql); if ($result->num_rows > 0) { // output data while($row =
$result->fetch_assoc()) { echo " content : " . $row["shujuku"]. "<br>"; } } else {
echo "0 result "; } $conn->close(); ?>
one , connect MYSQL

format : mysql -h Host address -u user name -p User password

1, Connect to the MYSQL.

Open it first DOS window , Then go to the directory mysql\bin, Type the command again mysql -u root
-p, Enter and prompt you to enter the password . Note that the user name can be preceded by spaces or no spaces , But there must be no space before the password , Otherwise, I will let you re-enter the password .

If it's just installed MYSQL, Super user root There is no password , So you can enter the MYSQL Yes ,MYSQL The prompt is : mysql>

2, Connect to the MYSQL. Assume that the IP by :110.110.110.110, The user name is root, The password is abcd123. Type the following command order :

mysql -h110.110.110.110 -u root -p 123;( notes :u And root You don't need to add spaces between them , It's the same with everything else )

3, sign out MYSQL command : exit ( enter )

two , Change Password

format :mysqladmin -u user name -p Old password password New password . for example

1, to root Add a password ab12. First of all DOS Go down to the directory mysql\bin, Then type the following command

mysqladmin -u root -password ab12

2, And then root Change your password to djg345.

mysqladmin -u root -p ab12 password ******

three , Create database

1, CREATE DATABASE Database name ;

2, GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON Database name .* TO
Database name @localhost IDENTIFIED BY ‘ password ’;

3, SET PASSWORD FOR

‘ Database name ’@‘localhost’ = OLD_PASSWORD(‘ password ’);

In turn 3 Create a database with two commands . be careful : chinese “ password ” and “ database ” It is set by the user .

—————————————————————————————————————————————

Now, let's introduce some common methods MYSQL command

be careful : You must first log in to MYSQL in , The following operations are performed in the MYSQL At the prompt of , And each command ends with a semicolon .

one , Operation skill

1, If you give orders , I forgot to add a semicolon after returning , You don't have to repeat the order , Just call a semicolon and enter .

That is to say, you can divide a complete command into several lines , Use semicolon to mark the end OK.

2, You can use the up and down keys of the cursor to call up the previous command .

two , Common commands

1, Displays a list of databases in the current database server :

mysql> SHOW DATABASES;

2, set up a database :

mysql> CREATE DATABASE Library name ;

mysql> CREATE DATABASE IF NOT EXISTS my_db default charset utf8 COLLATE
utf8_general_ci;

3, Establish data table :

mysql> USE Library name ;

mysql> CREATE TABLE Table name ( Field name VARCHAR(20), Field name CHAR(1));

4, Delete database :

mysql> DROP DATABASE Library name ;

5, Delete data table :

mysql> DROP TABLE Table name ;

6, Clear the records in the table :

mysql> DELETE FROM Table name ;

7, Insert record into table :

mysql> INSERT INTO Table name VALUES (“hyq”,“M”);

8, Update data in table :

mysql-> UPDATE Table name SET Field name 1=‘a’, Field name 2=‘b’ WHERE Field name 3=‘c’;

Technology