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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql和维信公众号_mysql实用指南

發布時間:2025/3/12 数据库 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql和维信公众号_mysql实用指南 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

mysqld --verbose --help:

可以顯示 mysql 的編譯配置選項,即功能配置描述。

mysql 顯示所有支持的字符集:????? SHOW CHARACTER SET;

mysql 創建數據庫或表的時候設置是否大小寫敏感:

CREATE DATABASE test_database CHARACTER SET utf8 COLLATE utf8_general_cs; # 這句沒什么用處,見下面的解釋。 cs 意思是 case sensitive

當然你也可以在創建結束后使用alter來改變:

ALTER TABLE table_name MODIFY column_name column_datatype COLLATE utf8_general_ci; # 這句有效果, ci 意思是 case insensitive

但是,記住,mysql的database和table都是操作系統的文件系統的目錄或文件名,因此不管你在創建他們時是否設置了大小寫敏感,他們都是和操作系統相關的,即windows上數據庫名和表名是大小寫無關的,而再linux上是大小寫敏感的。

只有表的column是和操作系統無關的,因為他們不是目錄入口,因此你可以在創建column時設置column名是否大小寫相關,也可以使用alter來修改大小寫敏感否。

如果真的需要在linux下設置數據庫名和table名大小寫無關的話,可以考慮使用lower_case_table_names變量,但不保證有效,可以了解下:

lower_case_table_names:

https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_lower_case_table_names

If set to 0, table names are stored as specified and comparisons are case sensitive. If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases. For additional information, see Section?9.2.2, “Identifier Case Sensitivity”.

mysql 的配置文件my.cnf調用次序(mysqld --verbose --help 的輸出里有以下打印):

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

Installation(完整的安裝幫助參考 INSTALL-BINARY 文件):

To install and use a MySQL binary distribution, the basic command sequence looks like this:

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

shell> chown -R mysql .

shell> chgrp -R mysql .

shell> scripts/mysql_install_db --user=mysql

shell> chown -R root .

shell> chown -R mysql data

shell> bin/mysqld_safe --user=mysql &

# Next command is optional

shell> cp support-files/mysql.server /etc/init.d/mysql.server

指定自己的 my.cnf 配置文件:

mysqld_safe --defaults-file=FILE

若運行時找不到 libaio.so ,? 可以:? sudo apt-get install libaio1 libaio-dev

首次啟動時修改mysql的 root@'localhost' 的密碼:

$ ./bin/mysql -uroot

mysql >? SET PASSWORD FOR root@'localhost' = PASSWORD('your_passwd');

mysql >?FLUSH PRIVILEGES;

下次登錄就要:? ./bin/mysql -uroot -p

修改密碼:

$ mysqladmin -u root -p password newpassword

Adding User Accounts

You can create MySQL accounts two ways:

By using account-management statements intended for creating accounts and establishing their privileges, such as CREATE USER and GRANT. These statements cause the server to make appropriate modifications to the underlying grant tables.

By manipulating the MySQL grant tables directly with statements such as INSERT, UPDATE, or DELETE.

The preferred method is to use account-management statements because they are more concise and less error-prone than manipulating the grant tables directly. All such statements are described in Section?13.7.1, “Account Management Statements”. Direct grant table manipulation is discouraged, and is not described here. The server is free to ignore rows that become malformed as a result of such modifications.

Another option for creating accounts is to use the GUI tool MySQL Workbench. Also, several third-party programs offer capabilities for MySQL account administration. phpMyAdmin is one such program.

The following examples show how to use the mysql client program to set up new accounts. These examples assume that privileges have been set up according to the defaults described in Section?2.12.4, “Securing the Initial MySQL Accounts”. This means that to make changes, you must connect to the MySQL server as the MySQL root user, which has the CREATE USER privilege.

First, use the mysql program to connect to the server as the MySQL root user:

shell> mysql --user=root mysql

If you have assigned a password to the root account, you must also supply a --password or -p option.

After connecting to the server as root, you can add new accounts. The following example uses CREATE USER and GRANT statements to set up four accounts:

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'

-> WITH GRANT OPTION;

mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'

-> WITH GRANT OPTION;

mysql> CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin_pass';

mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';

mysql> CREATE USER 'dummy'@'localhost';

The accounts created by those statements have the following properties:

Two accounts have a user name of monty and a password of some_pass. Both are superuser accounts with full privileges to do anything. The 'monty'@'localhost' account can be used only when connecting from the local host. The 'monty'@'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.

The 'monty'@'localhost' account is necessary if there is an anonymous-user account for localhost. Without the 'monty'@'localhost' account, that anonymous-user account takes precedence when monty connects from the local host and monty is treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'monty'@'%' account and thus comes earlier in the user table sort order. (user table sorting is discussed in Section?6.2.4, “Access Control, Stage 1: Connection Verification”.)

The 'admin'@'localhost' account has a password of admin_pass. This account can be used only by admin to connect from the local host. It is granted the RELOAD and PROCESS administrative privileges. These privileges enable the admin user to execute the mysqladmin reload, mysqladmin refresh, and mysqladmin flush-xxx commands, as well as mysqladmin processlist . No privileges are granted for accessing any databases. You could add such privileges using GRANT statements.

The 'dummy'@'localhost' account has no password (which is insecure and not recommended). This account can be used only to connect from the local host. No privileges are granted. It is assumed that you will grant specific privileges to the account using GRANT statements.

To see the privileges for an account, use SHOW GRANTS:

mysql> SHOW GRANTS FOR 'admin'@'localhost';

+-----------------------------------------------------+

| Grants for admin@localhost |

+-----------------------------------------------------+

| GRANT RELOAD, PROCESS ON *.* TO 'admin'@'localhost' |

+-----------------------------------------------------+

The next examples create three accounts and grant them access to specific databases. Each of them has a user name of custom and password of obscure:

mysql> CREATE USER 'custom'@'localhost' IDENTIFIED BY 'obscure';

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP

-> ON bankaccount.*

-> TO 'custom'@'localhost';

mysql> CREATE USER 'custom'@'host47.example.com' IDENTIFIED BY 'obscure';

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP

-> ON expenses.*

-> TO 'custom'@'host47.example.com';

mysql> CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'obscure';

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP

-> ON customer.*

-> TO 'custom'@'%.example.com';

The three accounts can be used as follows:

The first account can access the bankaccount database, but only from the local host.

The second account can access the expenses database, but only from the host host47.example.com.

The third account can access the customer database, from any host in the example.com domain. This account has access from all machines in the domain due to use of the “%” wildcard character in the host part of the account name.

對于java ssh項目,一般情況下只需要添加 'monty'@'localhost' 這樣的一個用戶就行了,所有的遠程訪問都是通過他進行的,所以不需要 'monty'@'%' 這個用戶。這個用戶不安全。

實例:

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';

CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

Then

GRANT ALL PRIVILEGES ON dbTest.* TO 'myuser'@'localhost';

GRANT ALL ON *.* TO 'myuser'@'localhost';

GRANT ALL ON *.* TO 'myuser'@'%';

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的mysql和维信公众号_mysql实用指南的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。