我正在尝试远程连接到Ubuntu中的数据库,但是在尝试进行mysql -u root -p以下操作时收到错误消息:
mysql -u root -p
在第1行的配置文件/etc/mysql/my.cnf中找到没有前一组的选项
my.cnf看起来像:
[mysqld] user = mysql socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp bind-address = 0.0.0.0 key_buffer = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 myisam-recover = BACKUP query_cache_limit = 1M query_cache_size = 16M log_error = /var/log/mysql/error.log expire_logs_days = 10 max_binlog_size = 100M [client] port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqldump] quick quote-names max_allowed_packet = 16M [mysql] [isamchk] key_buffer = 16M
检查文件的字符集编码。确保它是ASCII码。
例如,使用od命令查看开头是否有UTF-8 BOM。
od