日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

mysql 重启 及编码问题

發(fā)布時(shí)間:2023/12/13 综合教程 21 生活家
生活随笔 收集整理的這篇文章主要介紹了 mysql 重启 及编码问题 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Failed to start mysql.service Unit not found.

執(zhí)行完yum安裝命令后發(fā)現(xiàn)竟然無法啟動(dòng)錯(cuò)誤提示如下

[root@localhost ~]# systemctl start mysql.service

Failed to start mysql.service: Unit mysql.service not found.

查了半天資料,終于了解到MariaDB代替了mysql數(shù)據(jù)庫(kù)

因此用上述命令啟動(dòng)不起來,正確的方法如下

# yum install mariadb -y //如果已安裝可以省略

# systemctl start mariadb.service //啟動(dòng)服務(wù)

# systemctl enable mariadb.service //開機(jī)啟動(dòng)服務(wù)

# mysql -u root -p //登錄mysql
————————————————
版權(quán)聲明:本文為CSDN博主「佐手烈焰魂」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/qq_38286347/article/details/85060407

Access denied for user 'root'@'localhost' (using password: NO)

update user set authentication_string=password('root') where Host='localhost' and User='root';
flush privileges;


新版本要解決這個(gè)問題,步驟大致如下:

在系統(tǒng)偏好設(shè)置中關(guān)閉mysql服務(wù)
用安全模式啟動(dòng)服務(wù):sudo mysqld_safe --skip-grant-tables
mysql -u root 登錄,因?yàn)榘踩J较拢詿o需輸入密碼
登錄后進(jìn)行密碼修改(密碼修改這部分mysql做了很大的改動(dòng))

use mysql
select * from user;
update mysql.user set authentication_string=password('root') where user='root';
update mysql.user set Host='localhost' where user='root';
flush privileges;

密碼字段已經(jīng)不是之前的Password,新版本改為了現(xiàn)在的authentication_string字段
如果不按照這個(gè)步驟會(huì)報(bào)錯(cuò):Access denied for user 'root'@'localhost' (using password: NO)
最后就可以用 mysql -uroot -p 然后輸入上面設(shè)置的密碼登錄進(jìn)mysql了
官方對(duì)于重置密碼的解釋

作者:China_ly
鏈接:https://www.jianshu.com/p/aed44bff2711
來源:簡(jiǎn)書
著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。


MYSQL中文亂碼以及character_set_database屬性修改

新安裝MYSQL,還沒有修改數(shù)據(jù)庫(kù)系統(tǒng)編碼。

之后由于創(chuàng)建數(shù)據(jù)庫(kù)時(shí)候:create database db_name; 沒有指定編碼,之后發(fā)現(xiàn)亂碼就修改各個(gè)屬性之后還是亂碼,便開始配置數(shù)據(jù)庫(kù)屬性,之后信息如下:

+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

發(fā)現(xiàn)character_set_database該屬性設(shè)置utf8之后依舊還是Latin1 ,其實(shí)這個(gè)屬性是數(shù)據(jù)庫(kù)屬性,在創(chuàng)建數(shù)據(jù)庫(kù)時(shí)候如果不指定默認(rèn)就是這個(gè),因此對(duì)于創(chuàng)建的數(shù)據(jù)庫(kù)可以修改數(shù)據(jù)庫(kù)編碼為utf8,修改腳本:

alter database <數(shù)據(jù)庫(kù)名> character set utf8;

之后還是亂碼,由于之前數(shù)據(jù)錯(cuò)誤編碼,所以設(shè)置utf8依舊亂碼,刪除數(shù)據(jù)重新導(dǎo)入即可。因此為了避免此問題,以后安裝數(shù)據(jù)庫(kù)首要任務(wù)就是配置編碼,創(chuàng)建數(shù)據(jù)庫(kù)時(shí)候指定編碼:


Mysql2::Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation

1、去zabbix數(shù)據(jù)庫(kù)主機(jī)查看數(shù)據(jù)庫(kù)字符集。

show variables like '%char%';
1

可以看到 character_set_database和character_set_server的字符集都不是utf8的所以需要進(jìn)行設(shè)置。
2、修改數(shù)據(jù)庫(kù)配置文件(默認(rèn)在/etc/my.cnf),增加如下配置:

[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8

重啟數(shù)據(jù)庫(kù)
3、登錄后再次執(zhí)行show variables like '%char%';結(jié)果都是utf8了,如下:

4、重新導(dǎo)入zabbix數(shù)據(jù)模型。
————————————————
版權(quán)聲明:本文為CSDN博主「宮凱寧」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_44723434/article/details/89145881

-bash-4.2# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service

Failed to restart mysqld.service: Unit not found

并不存在mysqld 的服務(wù),

-bash-4.2# 
-bash-4.2# chkconfig -list
-list: unknown option
-bash-4.2# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use ‘systemctl list-unit-files‘.
      To see services enabled on particular target use
      ‘systemctl list-dependencies [target]‘.

aegis           0:off   1:off   2:on    3:on    4:on    5:on    6:off
agentwatch      0:off   1:off   2:on    3:on    4:on    5:on    6:off
iprdump         0:off   1:off   2:on    3:on    4:on    5:on    6:off
iprinit         0:off   1:off   2:on    3:on    4:on    5:on    6:off
iprupdate       0:off   1:off   2:on    3:on    4:on    5:on    6:off
jexec           0:off   1:on    2:on    3:on    4:on    5:on    6:off
mysql.server    0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off



總結(jié)

以上是生活随笔為你收集整理的mysql 重启 及编码问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。