安裝
現(xiàn)在,我們將通過 apt 包管理器安裝 MySQL。執(zhí)行下udo apt install mysql-server。具體日志如下:
cat@lubancat:~/lugl/my_project$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
accountsservice-ubuntu-schemas activity-log-manager apg aptdaemon aptdaemon-data cracklib-runtime gedit
gedit-common gir1.2-accountsservice-1.0 gir1.2-adw-1 gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdesktopenums-3.0
gir1.2-gdm-1.0 gir1.2-geoclue-2.0 gir1.2-gnomebluetooth-3.0 gir1.2-gnomedesktop-3.0 gir1.2-graphene-1.0
gir1.2-gtk-4.0 gir1.2-gtksource-4 gir1.2-gweather-3.0 gir1.2-javascriptcoregtk-4.0 gir1.2-json-1.0
gir1.2-mutter-10 gir1.2-nma-1.0 gir1.2-peas-1.0 gir1.2-rsvg-2.0 gir1.2-soup-2.4 gir1.2-upowerglib-1.0
gir1.2-vte-2.91 gkbd-capplet gnome-bluetooth-3-common gnome-bluetooth-common gnome-control-center-data
gnome-control-center-faces gnome-menus gnome-remote-desktop gnome-settings-daemon gnome-shell-common
gsfonts imagemagick-6-common language-selector-gnome libabsl20210324 libadwaita-1-0 libcolord-gtk1
libcrack2 libdca0 libde265-0 libdee-1.0-4 libdjvulibre-text libdjvulibre21 libebackend-1.2-10
libebook-1.2-20 libebook-contacts-1.2-3 libedata-book-1.2-26 libedata-cal-2.0-1 libfaad2
libfftw3-double3 libfluidsynth3 libfreeaptx0 libfreerdp-client2-2 libfreerdp-server2-2 libfreerdp2-2
libgdm1 libgeoclue-2-0 libgeocode-glib0 libgeonames-common libgeonames0 libgjs0g libgnome-autoar-0-0
libgnome-bluetooth-3.0-13 libgnome-bluetooth13 libgnome-menu-3-0 libgnomekbd8 libgsound0 libgspell-1-2
libgspell-1-common libgssdp-1.2-0 libgtksourceview-4-0 libgtksourceview-4-common libgupnp-1.2-1
libgupnp-av-1.0-3 libgupnp-igd-1.0-4 libgweather-3-16 libgweather-common libheif1 libinstpatch-1.0-2
libjxr-tools libjxr0 libkate1 liblqr-1-0 libltc11 libmagickcore-6.q16-6 libmagickcore-6.q16-6-extra
libmagickwand-6.q16-6 libmediaart-2.0-0 libmjpegutils-2.1-0 libmodplug1 libmozjs-102-0 libmpcdec6
libmpeg2encpp-2.1-0 libmplex2-2.1-0 libmutter-10-0 libnice10 libopenh264-6 libopenni2-0 libpeas-1.0-0
libpeas-common libphonenumber8 libprotobuf23 libpulsedsp libpwquality-common libpwquality1 libqrencode4
libqt5multimedia5 libqt5multimediaquick5 libqt5multimediawidgets5 librest-0.7-0 librygel-core-2.6-2
librygel-db-2.6-2 librygel-renderer-2.6-2 librygel-server-2.6-2 libsoundtouch1 libsoup-gnome2.4-1
libspandsp2 libspeexdsp1 libsrtp2-1 libtimezonemap-data libtimezonemap1 libtumbler-1-0
libunity-control-center1 libvncserver1 libvo-aacenc0 libvo-amrwbenc0 libwhoopsie-preferences0
libwildmidi2 libwinpr2-2 libwmflite-0.2-7 libxcb-xv0 libxcvt0 libzbar0 libzeitgeist-2.0-0 libzxingcore1
mutter-common power-profiles-daemon pulseaudio-utils python3-aptdaemon python3-aptdaemon.gtk3widgets
python3-defer python3-macaroonbakery python3-nacl python3-protobuf python3-pymacaroons python3-rfc3339
python3-tz qml-module-qtmultimedia switcheroo-control timgm6mb-soundfont tumbler-common
ubuntu-wallpapers ubuntu-wallpapers-jammy whoopsie whoopsie-preferences xwayland yaru-theme-gnome-shell
zeitgeist-core zenity-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libaio1 libcgi-fast-perl libcgi-pm-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl
libmecab2 libprotobuf-lite23 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
Suggested packages:
libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
libaio1 libcgi-fast-perl libcgi-pm-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl
libmecab2 libprotobuf-lite23 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 18 newly installed, 0 to remove and 95 not upgraded.
Need to get 28.4 MB of archives.
After this operation, 236 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 mysql-common all 5.8+1.0.8 [7212 B]
Get:2 http://mirrors.ustc.edu.cn/ubuntu-ports jammy-security/main arm64 mysql-client-core-8.0 arm64 8.0.32-0ubuntu0.22.04.2 [2877 kB]
Get:3 http://mirrors.ustc.edu.cn/ubuntu-ports jammy-security/main arm64 mysql-client-8.0 arm64 8.0.32-0ubuntu0.22.04.2 [22.7 kB]
Get:4 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libaio1 arm64 0.3.112-13build1 [7018 B]
Get:5 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libmecab2 arm64 0.996-14build9 [188 kB]
Get:6 http://mirrors.ustc.edu.cn/ubuntu-ports jammy-security/main arm64 libprotobuf-lite23 arm64 3.12.4-1ubuntu7.22.04.1 [192 kB]
Get:7 http://mirrors.ustc.edu.cn/ubuntu-ports jammy-security/main arm64 mysql-server-core-8.0 arm64 8.0.32-0ubuntu0.22.04.2 [16.9 MB]
Get:8 http://mirrors.ustc.edu.cn/ubuntu-ports jammy-security/main arm64 mysql-server-8.0 arm64 8.0.32-0ubuntu0.22.04.2 [1230 kB]
Get:9 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libcgi-pm-perl all 4.54-1 [188 kB]
Get:10 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libfcgi0ldbl arm64 2.4.2-2build2 [28.0 kB]
Get:11 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libfcgi-perl arm64 0.82+ds-1build1 [22.3 kB]
Get:12 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libcgi-fast-perl all 1:2.15-1 [10.5 kB]
Get:13 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libfcgi-bin arm64 2.4.2-2build2 [10.7 kB]
Get:14 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 libhtml-template-perl all 2.97-1.1 [59.1 kB]
Get:15 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 mecab-utils arm64 0.996-14build9 [4830 B]
Get:16 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 mecab-ipadic all 2.7.0-20070801+main-3 [6718 kB]
Get:17 http://mirrors.ustc.edu.cn/ubuntu-ports jammy/main arm64 mecab-ipadic-utf8 all 2.7.0-20070801+main-3 [4384 B]
Get:18 http://mirrors.ustc.edu.cn/ubuntu-ports jammy-security/main arm64 mysql-server all 8.0.32-0ubuntu0.22.04.2 [9458 B]
Fetched 28.4 MB in 2s (11.9 MB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 159629 files and directories currently installed.)
Preparing to unpack .../0-mysql-common_5.8+1.0.8_all.deb ...
Unpacking mysql-common (5.8+1.0.8) ...
Selecting previously unselected package mysql-client-core-8.0.
Preparing to unpack .../1-mysql-client-core-8.0_8.0.32-0ubuntu0.22.04.2_arm64.deb ...
Unpacking mysql-client-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package mysql-client-8.0.
Preparing to unpack .../2-mysql-client-8.0_8.0.32-0ubuntu0.22.04.2_arm64.deb ...
Unpacking mysql-client-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package libaio1:arm64.
Preparing to unpack .../3-libaio1_0.3.112-13build1_arm64.deb ...
Unpacking libaio1:arm64 (0.3.112-13build1) ...
Selecting previously unselected package libmecab2:arm64.
Preparing to unpack .../4-libmecab2_0.996-14build9_arm64.deb ...
Unpacking libmecab2:arm64 (0.996-14build9) ...
Selecting previously unselected package libprotobuf-lite23:arm64.
Preparing to unpack .../5-libprotobuf-lite23_3.12.4-1ubuntu7.22.04.1_arm64.deb ...
Unpacking libprotobuf-lite23:arm64 (3.12.4-1ubuntu7.22.04.1) ...
Selecting previously unselected package mysql-server-core-8.0.
Preparing to unpack .../6-mysql-server-core-8.0_8.0.32-0ubuntu0.22.04.2_arm64.deb ...
Unpacking mysql-server-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up mysql-common (5.8+1.0.8) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-8.0.
(Reading database ... 159843 files and directories currently installed.)
Preparing to unpack .../00-mysql-server-8.0_8.0.32-0ubuntu0.22.04.2_arm64.deb ...
Unpacking mysql-server-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../01-libcgi-pm-perl_4.54-1_all.deb ...
Unpacking libcgi-pm-perl (4.54-1) ...
Selecting previously unselected package libfcgi0ldbl:arm64.
Preparing to unpack .../02-libfcgi0ldbl_2.4.2-2build2_arm64.deb ...
Unpacking libfcgi0ldbl:arm64 (2.4.2-2build2) ...
Selecting previously unselected package libfcgi-perl:arm64.
Preparing to unpack .../03-libfcgi-perl_0.82+ds-1build1_arm64.deb ...
Unpacking libfcgi-perl:arm64 (0.82+ds-1build1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../04-libcgi-fast-perl_1%3a2.15-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.15-1) ...
Selecting previously unselected package libfcgi-bin.
Preparing to unpack .../05-libfcgi-bin_2.4.2-2build2_arm64.deb ...
Unpacking libfcgi-bin (2.4.2-2build2) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../06-libhtml-template-perl_2.97-1.1_all.deb ...
Unpacking libhtml-template-perl (2.97-1.1) ...
Selecting previously unselected package mecab-utils.
Preparing to unpack .../07-mecab-utils_0.996-14build9_arm64.deb ...
Unpacking mecab-utils (0.996-14build9) ...
Selecting previously unselected package mecab-ipadic.
Preparing to unpack .../08-mecab-ipadic_2.7.0-20070801+main-3_all.deb ...
Unpacking mecab-ipadic (2.7.0-20070801+main-3) ...
Selecting previously unselected package mecab-ipadic-utf8.
Preparing to unpack .../09-mecab-ipadic-utf8_2.7.0-20070801+main-3_all.deb ...
Unpacking mecab-ipadic-utf8 (2.7.0-20070801+main-3) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../10-mysql-server_8.0.32-0ubuntu0.22.04.2_all.deb ...
Unpacking mysql-server (8.0.32-0ubuntu0.22.04.2) ...
Setting up libmecab2:arm64 (0.996-14build9) ...
Setting up mysql-client-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up libfcgi0ldbl:arm64 (2.4.2-2build2) ...
Setting up libcgi-pm-perl (4.54-1) ...
Setting up libfcgi-bin (2.4.2-2build2) ...
Setting up libhtml-template-perl (2.97-1.1) ...
Setting up libprotobuf-lite23:arm64 (3.12.4-1ubuntu7.22.04.1) ...
Setting up mecab-utils (0.996-14build9) ...
Setting up mysql-client-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up libfcgi-perl:arm64 (0.82+ds-1build1) ...
Setting up libaio1:arm64 (0.3.112-13build1) ...
Setting up mecab-ipadic (2.7.0-20070801+main-3) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|
done!
update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up libcgi-fast-perl (1:2.15-1) ...
Setting up mysql-server-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up mecab-ipadic-utf8 (2.7.0-20070801+main-3) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|
done!
update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.32-0ubuntu0.22.04.2) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 3901
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.32-0ubuntu0.22.04.2) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
我們看到mysqld is running as pid 3901,說明mysql服務(wù)已經(jīng)啟動,當(dāng)然我們也可以用命令sudo service mysql status來查看信息:
cat@lubancat:~/lugl/my_project$ sudo service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-04-26 18:07:49 CST; 4min 35s ago
Process: 4076 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4084 (mysqld)
Status: "Server is operational"
Memory: 364.6M
CPU: 7.808s
CGroup: /system.slice/mysql.service
└─4084 /usr/sbin/mysqld
進(jìn)入mysql控制臺:
cat@lubancat:~/lugl/my_project$ sudo mysql
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 8
Server version: 8.0.32-0ubuntu0.22.04.2 (Ubuntu)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.
mysql>
在這里我就可以進(jìn)入命令行的日常操作了
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
| debian-sys-maint | $A$005$}ZCg'cRfV3C8yInxkte5T9evBgjAOj45tRKiyXQP4fyYgikL.UambrqdlC | caching_sha2_password | localhost |
| mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| root | | auth_socket | localhost |
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
5 rows in set (0.01 sec)
輸入以下命修改登錄密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Temppwd123@'
-> ;
Query OK, 0 rows affected (0.25 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.04 sec)
mysql>
完成后,我們需要確認(rèn) root 用戶不再使用 auth_socket 進(jìn)行身份驗(yàn)證。通過再次運(yùn)行以下命令來執(zhí)行此操作。
mysql> create user 'root'@'192.168.3.192' identified by 'password'
-> ^C
mysql> create user 'root'@'192.168.3.192' identified by 'Temppwd123@';
Query OK, 0 rows affected (0.07 sec)
mysql> grant all privileges on . to 'root'@'192.168.3.192' with grant option
-> ;
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql>
安裝pymysql
執(zhí)行sudo apt install python3-pymysql
測試
cat@lubancat:~$ python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
>>> conn = pymysql.connect(host='127.0.0.1',database='mysql',user='root',password='Temppwd123@')
>>> print(conn)
到此,mysql了安裝成功,并完成了測試。
審核編輯:湯梓紅
-
測試
+關(guān)注
關(guān)注
8文章
5103瀏覽量
126340 -
門禁系統(tǒng)
+關(guān)注
關(guān)注
17文章
391瀏覽量
45436 -
MySQL
+關(guān)注
關(guān)注
1文章
798瀏覽量
26399
發(fā)布評論請先 登錄
相關(guān)推薦
評論