MySQL-0-Overview-Introduction and Installation (Win10, DataGrip, Ubuntu18.04 remote connection)

B station learning video source

a brief introdction

Programmers use SQL to control the database management system (MySQL) to operate on the database.
insert image description hereMySQL

data model

insert image description here

The dept_id of Zhang Wuji in the first table is 1, and this dept_id is the id of the second table. These tables are connected to each other, so they become a relational database.

insert image description hereUsers can create a database by using a relational database (DBMS), create a data table in the database, and further create data in the data table. This is the data model of MySQL.


Win10 installation

insert image description hereThe installation can be installed according to this blog MySQL (detailed, suitable for novices) , very simple.

environment variable

Here I will talk about the configuration after installation. First, you can configure the environment variables, so that you don’t have to start it in the bin\ directory every time.
as follows:
insert image description here
insert image description here

insert image description hereJust add a path, which is the location corresponding to bin\.
insert image description hereThen make sure all the way, exit, and re-enter mysql.

change Password

  1. To run cmd (command prompt) as an administrator, you must be an administrator, and it will be the same in the future.
  2. Enter net start mysql, start successfully
  3. Enter mysql -u root -p, success after entering the password
    insert image description here
  4. Enter ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';the password is the password you want to set,
    for example ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';, remember to add a semicolon, and then you can use the new password for the next login.

Create a startup script

Create a new text on the desktop, rename it, and change it to a file with the suffix .bat

insert image description here

Then copy the following code and save it. Note that after -p is your own password, write directly next to -p without spaces .

@%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0"
net start mysql
mysql -u root -p123456
@net stop mysql

Then double-click to run this file to automatically open mysql.
When exiting, enter quit;, you can automatically exit mysql and stop the service.
insert image description here

Currently there is the latest permanent version. Considering the problem of resources, please private message me if you need it.

Install DataGrip2021.2

Install the old version, you can try the 30-day version for free,
insert image description heredownload the compressed package
insert image description here
, then unzip it to your designated directory, enter the bin file, find the exe, insert image description here
right-click to create a shortcut, drag it to the desktop, and then rename it.

Download another file: https://pan.baidu.com/s/1hM0ywuFxO3I51BjiVORMeQ
Extraction code: gzua

Then open DataGrip, apply for 30 days of use, and then create a project

After entering the project, manually drag the file to the gray area in the middle, and restart when prompted to restart.
insert image description hereAfter restarting, click Help to see the name of the plugin below, and you can use it casually in the future.
insert image description here
Then find the MySQL in the data source on the plus sign on the left and configure it. Remember to start the mysql service before testing the connection.

Install MySQL on ubuntu18.04

Install

Open the command line and enter the following commands in sequence:

  1. sudo apt-get update

  2. sudo apt-get install mysql-server

  3. Enter sudo mysql -u root -p
    Enter the password as root to enter mysql.
    But now you have to use sudo to enter mysql, we can fix this as shown below.

  4. update user set plugin = 'mysql_native_password' where user = 'root';

    • mysql_native_password is the encryption method of mysql5.7 version (ubuntu18.04 uses this).
    • caching_sha2_password is the encryption method of mysql8.0 version.
  5. quit;

  6. sudo service mysql restartrestart the mysql service

  7. sudo mysql -u rootEnter mysql without password

  8. ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';Change password
    (123456 is the login password to be changed)

  9. quit;

  10. mysql -u root -p
    Then enter the password you just modified to log in normally.

remote link

Because our current user is 'root'@'localhost', that is to say, the root user can only log in to the database at localhost (local). If we want to access it in windows, we must create a new user

  1. CREATE USER 'root'@'%' identified with mysql_native_password by '1234';

  2. Assign it all permissions:grant all on *.* to 'root'@'%';

  3. quit;

  4. Enter sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf, modify the file, comment out bing-address, then save and exit
    insert image description here

  5. restart mysql:sudo service mysql restart

  6. Enter ifconfigto view the ip of ubuntuinsert image description here

  7. Log in to DataGrip and connect to mysql under Windows.
    insert image description here

Guess you like

Origin blog.csdn.net/qq_49030008/article/details/126603305