Ubuntu18.04下QT和MYSQL异常问题排查处理常用命令

问题场景 :开年第一天上班,使用GIT下载好项目代码到本地后,发现QT5.14.2无法正常启动,使用命令sudo /opt/Qt5.14.2/Tools/QtCreator/bin/qtcreator后没有任何反应,仔细回想应该是年前电脑修改环境变量导致无法进入系统和QT里面安装中文输入法导致的后续一系列的改变。

错误提示:

xqf222@ubuntupc:~/QtCode/20230128$ sudo /opt/Qt5.14.2/Tools/QtCreator/bin/qtcreator
[sudo] xqf222 的密码:
Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Got keys from plugin meta data ("ibus")
QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.14.2/Tools/QtCreator/bin/platforminputcontexts" ...
loaded library "/opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
Cannot mix incompatible Qt library (version 0x50e02) with this library (version 0x50e01)
已放弃 (核心已转储)

处理办法:

1.环境变量问题:

打开终端命令,输入sudo vi /etc/profile执行,删除配置中的多余内容:

export XDG_RUNTIME_DIR=/usr/lib/
export RUNLEVEL=3

保留QT配置部分内容:

export QT_SELECT=Qt5.14.2
export QTDIR=/opt/Qt5.14.2/5.14.2/gcc_64
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PAtH
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
export PATH=$PATH:${JAVA_HOME}/bin
export M2_HOME=/opt/apache-maven-3.8.7
export PATH=$PATH:${M2_HOME}/bin
export DISPLAY=:0.0

修改完成后按ESC键,输入小写qw保存退出编辑,之后输入source /etc/profile命令刷新环境变量配置

 修改当前用户环境变量,尽量和系统的环境变量一致:

修改命令:sudo gedit /etc/bash.bashrc,末尾自定义部分内容如下:

export QT_SELECT=Qt5.14.2
export QTDIR=/opt/Qt5.14.2/5.14.2/gcc_64
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PAtH
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
export PATH=$PATH:${JAVA_HOME}/bin
export M2_HOME=/opt/apache-maven-3.8.7
export PATH=$PATH:${M2_HOME}/bin
export DISPLAY=:0.0

刷新命令:source /etc/bash.bashrc

2.卸载处理中文输入法操作:

sudo apt-get  remove ibus
sudo apt-get  purge  ibus
sudo  apt-get remove indicator-keyboard
sudo apt-get install  fcitx
sudo apt-get install  fcitx-pinyin
sudo apt install unity-control-center

安装中文输入法

sudo apt-get install fcitx-frontend-qt5

ibus-setup
//拷贝文件1
cd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts
ls
cd /opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforminputcontexts
sudo cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so .
sudo cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so .
//设置权限1
sudo chmod 777 libfcitxplatforminputcontextplugin.so
sudo chmod 777 libibusplatforminputcontextplugin.so
chmod +x libfcitxplatforminputcontextplugin.so  
//拷贝文件2
cd /opt/Qt5.14.2/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts
ls
sudo cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so .
sudo cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so .
//设置权限3
sudo chmod 777 libfcitxplatforminputcontextplugin.so  
sudo chmod 777 libibusplatforminputcontextplugin.so
chmod +x libfcitxplatforminputcontextplugin.so 

删除驱动文件命令

sudo rm /opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so
sudo rm /opt/Qt5.14.2/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so
cd /opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforminputcontexts/
ls
cd /opt/Qt5.14.2/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts/
ls

3.卸载默认的QT4和QT5

卸载qt4命令:
sudo apt-get autoremove --purge libqt4-[a-z]*

安装qt5命令:
sudo apt-get install qt5-default

sudo apt install qtcreator

卸载qt5命令:

sudo apt-get remove qt5-default qtcreator

sudo apt-get install fcitx-libs-qt5
dpkg -L fcitx-frontend-qt5 | grep .so

sudo apt-get install gcc g++
sudo apt-get install build-essential
cd /usr/lib/x86_64-linux-gnu/qt-default/qtchooser
sudo gedit default.conf

4.MySql驱动问题处理

sudo service mysql stop

sudo service mysql start

卸载mysql软件和驱动:
sudo apt-get autoremove --purge mysql-server
sudo apt-get remove mysql-common
sudo apt-get update
安装mysql软件和驱动:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysql++
sudo apt-get install libmysqlclient-dev

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疾风铸境

提供工作中碰到的和研究过的技术

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值