brew install mysql
启动
brew services start mysql@5.7
Error: Can't connect to local MySQL server through socket问题
这里遇到的启动不了mysql的问题,是因为之前安装的mysql8.x,后来又卸载了,重新安装mysql5.7,但数据没有清理干净,所以出现mysql启动不了的问题。可以这样解决:
- 检查/usr/local/Cellar目录是否有mysql文件,有的话删除。
- 检查/usr/local/var 里的mysql文件,有的话删除。
- 检查/tmp 里的mysql.sock、mysql.sock.lock、 my.cnf文件,有的话删除。
- err文件以及pid文件都是在/usr/local/var/mysql中,有的话删除。
- brew安装的安装包存储在/usr/local/Library/Cache/Homebrew,有的话删除。
- 一定要记得执行brew cleanup。
参考:https://www.jianshu.com/p/276c1271ae14
第一次启动需要设置密码
-> % sudo mysql_secure_installation
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: thinker
Please set the password for root here.
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
启动hive
hive --service metastore &
安装hive遇到的问题
1)启动hive的时候,遇到:Exception in thread "main" java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative...的错误
我已经把hive-log4j2.properties中的property.hive.log.dir 改成 /Users/majie/tools/bigdata/hive/logs/
但还不行,后来看到https://www.cnblogs.com/EnzoDin/p/7376707.html说hive-site.xml改三个配置项就可以了,分别是:
hive.exec.local.scratchdir
hive.downloaded.resources.dir
hive.server2.logging.operation.log.location
hive.querylog.location
里面千万不要有像system:name这种变量出现,不然启动不了。
2)mysql版本的问题
这里最好使用mysql5.7版本
3)hive使用schematool初始化,出错Failed to get schema version;Access denied for user 'hadoop'@'localhost'
这里是因为hive-site.xml中,使用了错误的用户名(我们用了hadoop),而实际上应该使用root
4)Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes
https://blog.csdn.net/ztchun/article/details/78944562
即在/usr/local/etc/my.cnf中,加上wait_timeout = 1814400,然后重启mysqld:brew services restart mysql@5.7
重启metastore:hive --service metastore &
连接sql
mysql -u root -p
关闭sql
brew services stop mysql@5.7
参考资料:
https://blog.csdn.net/w605283073/article/details/80417866
vim设置:https://blog.csdn.net/chuanj1985/article/details/6873830