mysql restart and coding problems MYSQL Chinese garbled attribute modification and character_set_database

Failed to start mysql.service Unit not found.

After executing the yum install command discovered they can not start the following error message

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

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

Check the information for a long time, I have finally learned MariaDB instead of mysql database

Thus with the above command start up, the correct method is as follows

# Yum install mariadb -y // If you have installed can be omitted

# Systemctl start mariadb.service // start the service

# Systemctl enable mariadb.service // start-up service

# Mysql -u root -p // login MySQL
----------------
Disclaimer: This article is CSDN blogger "Zuo hand flames soul" of the original article, follow the CC 4.0 BY- SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: 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;

 

The new version to solve this problem, the steps as follows:

  • Close mysql service in System Preferences
  • Safe mode to start the service:sudo mysqld_safe --skip-grant-tables
  • mysql -u root Log in as safe mode, so no password
  • After login password modification (password to modify this part of the mysql made a lot of changes)
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; 

Password field has not before Password, now replaced by a new version of the authentication_stringfield
if you do not follow this procedure will get an error: Access denied for user 'root'@'localhost' (using password: NO)
Finally you can mysql -uroot -pthen enter the password to log into mysql set above the
official explanation for resetting your password



Author: China_ly
link: https://www.jianshu.com/p/aed44bff2711
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.
 
 
 

MYSQL Chinese garbled attribute modification and character_set_database

 

The newly installed MYSQL, not modify the database system encoding.

After due time creating a database: create database db_name; do not specify the encoding, after the discovery of garbled after modifying individual properties or distortion, began to configure the database properties, after the information is as follows:

+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+

The property is set after the discovery character_set_database utf8 still or Latin1, in fact, this property is a property database, if you do not specify a default is this, when you create a database, so for database creation can be modified encoded as utf8 database, modify the script:

alter database <database name> character set utf8; 

After or distortion due to data errors before coding, so set utf8 still garbled, deleted data can be re-imported. Therefore, to avoid this problem, install the database after the primary task is to configure the encoding, create a database when the specified encoding:

 
 

 

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

1, to database host zabbix view the database character set.

show variables like '%char%';
1

You can see character_set_database and character_set_server character set is not utf8 So need to be set.
2, modify the configuration file database (default /etc/my.cnf), add the following configuration:

[MySQL]
default = utf8-Character-SET
[mysqld]
Character-Server-SET = utf8

restart the database
3, the log is performed again show variables like '% char%' ; utf8 the results are as follows:


4, re-import zabbix data model.
----------------
Disclaimer: This article is the original article CSDN bloggers' Palace Canning "and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: 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 service does not exist,

-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



The newly installed MYSQL, not modify the database system encoding.

After due time creating a database: create database db_name; do not specify the encoding, after the discovery of garbled after modifying individual properties or distortion, began to configure the database properties, after the information is as follows:

+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+

The property is set after the discovery character_set_database utf8 still or Latin1, in fact, this property is a property database, if you do not specify a default is this, when you create a database, so for database creation can be modified encoded as utf8 database, modify the script:

alter database <database name> character set utf8; 

After or distortion due to data errors before coding, so set utf8 still garbled, deleted data can be re-imported. Therefore, to avoid this problem, install the database after the primary task is to configure the encoding, create a database when the specified encoding:

Guess you like

Origin www.cnblogs.com/qinyan20/p/11728493.html